예제 #1
0
func main() {
	//Log
	TSLog.InitLogger("ServerLog")
	TSLog.SetLevel(TSLog.TraceLevel)
	fmt.Println("ServerLog init Success!")

	tcp := new(TSTCP)
	tcp.Create_Server(":9901",
		func() {
			fmt.Println("TCPServer Success! Port: 9901")
		},

		func(conn net.Conn) uint64 {
			AddUUID++
			fmt.Println("Client connect! UUID:", AddUUID)
			TSEngine.RegistClient(AddUUID, conn)
			return AddUUID
		},

		func(conn net.Conn, sBuffer []byte, UUID uint64) {
			fmt.Println("UUID:", UUID, " Recv:", string(sBuffer))
			TSEngine.ProcessMsg(sBuffer, UUID)
		},

		func(conn net.Conn, UUID uint64) {
			fmt.Println("Client close connect! UUID: ", UUID)
			TSEngine.UnregistClient(UUID)
		},
	)
}
예제 #2
0
func GoAdaptServer() {
	tcp := new(TSTCP)
	tcp.Create_Server(":"+TSUtil.ToString(TSCommon.GateWayAdaptServer_Port),
		func() {
			fmt.Println("网关适配服启动成功! Port:", TSUtil.ToString(TSCommon.GateWayAdaptServer_Port))
		},
		func(conn net.Conn) uint64 {
			UUID := adaptUUID_GW()
			Pool_GateWayServer[UUID] = &CGateWay{conn, UUID}
			fmt.Println("GateWay客户端上线! 获取动态UUID:", UUID)
			return UUID
		},
		func(conn net.Conn, sBuffer string, UUID uint64) {
			fmt.Println("GateWay客户端 Buffer", sBuffer, " UUID:", UUID)
		},
		func(conn net.Conn, UUID uint64) {
			fmt.Println("GateWay客户端下线!", UUID)
			Pool_GateWayServer[UUID] = nil
		},
	)
}
예제 #3
0
func GoGWServer() {
	tcp := new(TSTCP)
	tcp.Create_Server(TSCommon.GameAdaptServer_IP+":"+TSUtil.ToString(TSCommon.GameAdaptServer_Port),
		FunServerInit, FunConnectNew, FunReceiveBuffer, FunConnectClose)
}