Ejemplo n.º 1
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
		},
	)
}
Ejemplo n.º 2
0
func GoGWAdaptClient() {
	tcp := new(TSTCP)
	localhost := TSCommon.GateWayAdaptServer_IP + ":" + TSUtil.ToString(TSCommon.GateWayAdaptServer_Port)
	tcp.Create_Client(localhost,
		func(conn net.Conn) {
			fmt.Println("GW客户端连接成功!")
		},
		func(conn net.Conn, sBuffer string, UUID uint64) {
			fmt.Println("GW客户端Buffer:", sBuffer, " UUID:", UUID)
		},
		func(conn net.Conn, UUID uint64) {
			fmt.Println("GW客户端断开连接! UUID", UUID)
		})
}
Ejemplo n.º 3
0
func (this *TSTCP) Create_Server(webpath string, init ServerInit, funCN ConnectNew, funRB ReceiveBuffer, funCC ConnectClose) {
	listener, err := net.Listen("tcp", webpath)
	if err != nil {
		fmt.Println("Tcp listen at port 9188 failed, err", err.Error())
		return
	}
	init()
	for {
		this.conn, err = listener.Accept()
		if err != nil {
			fmt.Println("Accept failed, err", err.Error())
			return
		}
		fmt.Println("Accept connect.")
		UUID := funCN(this.conn)
		this.SendBuffer("_RegistUUID," + TSUtil.ToString(int(UUID)))
		go tcpHandler(this.conn, funRB, funCC, UUID)
	}
}
Ejemplo n.º 4
0
func GoGWServer() {
	tcp := new(TSTCP)
	tcp.Create_Server(TSCommon.GameAdaptServer_IP+":"+TSUtil.ToString(TSCommon.GameAdaptServer_Port),
		FunServerInit, FunConnectNew, FunReceiveBuffer, FunConnectClose)
}
Ejemplo n.º 5
0
func GoGameAdaptClient() {
	tcp = new(TSTCP)
	tcp.Create_Client(TSCommon.GameAdaptServer_IP+":"+TSUtil.ToString(TSCommon.GameAdaptServer_Port), FunClientInit, FunReceiveBuffer, FunConnectClose)
}