Пример #1
0
 public void sendMsgToClient(string msg, Socket serverSock, GlobalMessage msgType)
 {
     Fleck.IWebSocketConnection clientSock = myGlobals.ServerClient[serverSock];
     //long sock = clientSock.Handle.ToInt64();
     if (msgType == GlobalMessage.LOGINACKFAILED)
     {
         //toClient.DistributeMessage(bytes, clientSock);
         wsServer.sendMessage(clientSock, msg);
         closeServer(serverSock);
         closeClient(clientSock);
     }
     else if (msgType.Equals(GlobalMessage.LOGINACKOK))
     {
         //Heartbeat cTimer = new Heartbeat();
         //cTimer.timeout += new Heartbeat.timerDelegate(clientTimeout);
         clientHeartbeat cTimer = new clientHeartbeat();
         cTimer.timeout += new clientHeartbeat.timerDelegate(clientTimeout);
         cTimer.start();
         clientTimers.Add(clientSock, cTimer);
         //toClient.DistributeMessage(bytes, clientSock);
         wsServer.sendMessage(clientSock, msg);
     }
     else if (msgType == GlobalMessage.LOGOUTACKOK)
     {
         //toClient.DistributeMessage(bytes, clientSock);
         wsServer.sendMessage(clientSock, msg);
         closeServer(serverSock);
         closeClient(clientSock);
     }
     else
     {
         //toClient.DistributeMessage(bytes, clientSock);
         wsServer.sendMessage(clientSock, msg);
     }
 }
Пример #2
0
        public void sendMsgToClient(string msg, Socket serverSock, GlobalMessage msgType)
        {

            Fleck.IWebSocketConnection clientSock = myGlobals.ServerClient[serverSock];
            //long sock = clientSock.Handle.ToInt64();
            if (msgType == GlobalMessage.LOGINACKFAILED)
            {
                //toClient.DistributeMessage(bytes, clientSock);
                wsServer.sendMessage(clientSock, msg);
                closeServer(serverSock);
                closeClient(clientSock);
            }
            else if (msgType.Equals(GlobalMessage.LOGINACKOK))
            {
                //Heartbeat cTimer = new Heartbeat();
                //cTimer.timeout += new Heartbeat.timerDelegate(clientTimeout);
                clientHeartbeat cTimer = new clientHeartbeat();
                cTimer.timeout += new clientHeartbeat.timerDelegate(clientTimeout);
                cTimer.start();
                clientTimers.Add(clientSock, cTimer);
                //toClient.DistributeMessage(bytes, clientSock);
                wsServer.sendMessage(clientSock, msg);
            }
            else if (msgType == GlobalMessage.LOGOUTACKOK)
            {
                //toClient.DistributeMessage(bytes, clientSock);
                wsServer.sendMessage(clientSock, msg);
                closeServer(serverSock);
                closeClient(clientSock);
            }
            else
                //toClient.DistributeMessage(bytes, clientSock);
                wsServer.sendMessage(clientSock, msg);
        }