コード例 #1
0
        private void InitForClient()
        {
            forClient.Init("0.0.0.0", NetConfig.LISTENER_PORT);
            var addr = NetTool.GetAddress("0.0.0.0", NetConfig.LISTENER_PORT);

            Logger.LogInfo("初始化网络监听(客户端) [{0}]".FormatStr(addr));
        }
コード例 #2
0
ファイル: WebSocketClient.cs プロジェクト: wcsjb/XiaoGame_New
 public override void Setup(string ip, int port)
 {
     base.Setup(ip, port);
     _socket            = new WebSocketSharp.WebSocket(NetTool.GetAddress(ip, port) + "/default");
     _socket.OnOpen    += (a, b) => { base.OnConnected(); };
     _socket.OnClose   += (a, b) => { base.OnClosed(); };
     _socket.OnMessage += (a, b) => { base.OnReceived(b.RawData); };
 }
コード例 #3
0
        public void Login()
        {
            BMLoginRequest msg = new BMLoginRequest();

            msg.ListenerAddress = NetTool.GetAddress(NetConfig.LISTENER_IP, NetConfig.LISTENER_PORT);
            SendMessage <BMLoginRequest, BMLoginReply>(msg, (reply) =>
            {
                Logger.Log($"登录主服成功, 战场名: {reply.Name}");
            });
        }
コード例 #4
0
ファイル: WebSocketClient.cs プロジェクト: wcsjb/XiaoGame_New
 public override void Setup(string ip, int port)
 {
     base.Setup(ip, port);
     _socket           = new WebSocketSharp.WebSocket(NetTool.GetAddress(ip, port) + "/default");
     _socket.Log.Level = WebSocketSharp.LogLevel.Error;
     // _socket.WaitTime = TimeSpan.FromSeconds(1);
     _socket.OnOpen    += (a, b) => { base.OnConnected(); };
     _socket.OnClose   += (a, b) => { base.OnClosed(); };
     _socket.OnMessage += (a, b) => { base.OnReceived(b.RawData); };
 }
コード例 #5
0
 public override void Setup(string ip, int port)
 {
     base.Setup(ip, port);
     _server           = new WebSocketSharp.Server.WebSocketServer(NetTool.GetAddress(ip, port));
     _server.Log.Level = WebSocketSharp.LogLevel.Error;
     _server.AddWebSocketService(defaultServicePath, () =>
     {
         WebSocketSession session = new WebSocketSession(SendAction);
         session.onConnected      = () => { OnSessionConnected(session); };
         session.onClosed         = () => { OnSessionClosed(session); };
         session.onReceived       = (data) => { OnSessionReceived(session, data); };
         return(session.behavior);
     });
 }