Ejemplo n.º 1
0
func NewAuthServer(config *AuthServerConfig) *AuthServer {
	a := new(AuthServer)
	a.config = config
	a.TcpProtocolServer = base.NewTcpProtocolServer(config.Port)
	a.TcpProtocolServer.SetOperationHandler(func(conn net.Conn, id int, version byte, serverType byte, dataType byte, dataLen int, data []byte, raw []byte) {

	})

	a.TcpProtocolServer.SetConnectedHandler(func(conn net.Conn) {
		log.I_NET("connection server", conn.RemoteAddr(), "connnect to auth server success")
	})

	a.TcpProtocolServer.SetDisconnectedHandler(func() {
		log.W_NET("connection server disconnnect to auth server")
	})
	return a
}
Ejemplo n.º 2
0
func NewRouteServer(config *RouteServerConfig) *RouteServer {
	r := new(RouteServer)
	r.config = config

	r.TcpProtocolServer = base.NewTcpProtocolServer(config.Port)
	r.TcpProtocolServer.SetOperationHandler(func(conn net.Conn, id int, version byte, serverType byte, dataType byte, dataLen int, data []byte, raw []byte) {
		log.I_NET("reoute server recv from", conn.RemoteAddr(), ", data id :", id, ", version :", version,
			", server type :", serverType, ", data type :", dataType, ", data :", string(data))
		r.execute(conn, id, version, serverType, dataType, dataLen, data, raw)
	})

	r.TcpProtocolServer.SetConnectedHandler(func(conn net.Conn) {
		log.I_NET("client", conn.RemoteAddr().String(), "connect to route server", conn.LocalAddr().String(), "success")
	})

	r.TcpProtocolServer.SetDisconnectedHandler(func(conn net.Conn) {
		log.I_NET("client", conn.RemoteAddr().String(), "disconnect to route server", conn.LocalAddr().String())
	})
	return r
}