示例#1
0
文件: Demo.cs 项目: KosBeg/jwebsocket
 private void BooleanResponse(WebSocketTokenClient sender, TokenResponse e)
 {
     IToken lToken = e.TokenRecive;
     listBox1.Items.Add("Recived token [ type:" + lToken.GetType() + " - NS:" + lToken.GetNS() + " - utid:" + lToken.GetInt("utid") + " - data:" + lToken.GetBool("data") + " ]");
 }
示例#2
0
        protected override void OnReciveTextPacket(WebSocketProtocol aSender, IWebSocketPacket e)
        {
            if (recivePacket != null)
                recivePacket(aSender, e);
            try
            {
                JsonObject lTextjson = new JsonObject(e.GetString());

                IToken lToken = PacketToToken(e);
                string lType = lToken.GetType();

                lock (PendingResponseQueue)
                {
                    if (!lType.Equals(WebSocketMessage.WELCOME) && !lType.Equals(WebSocketMessage.GOODBYTE))
                    {
                        try
                        {
                            int lUTID = lToken.GetInt(WebSocketMessage.UTID);
                            int lCode = lToken.GetInt(WebSocketMessage.CODE);

                            PendingResponseQueue lPRQI = PendingResponseQueue[lUTID];
                            if (lPRQI != null)
                            {
                                bool lSuccess = false;
                                if (lCode == 0)
                                    lSuccess = true;

                                TokenResponse lResponse = new TokenResponse(mPendingResponseQueue[lUTID].Token, lToken, lSuccess);
                                lPRQI.PendingResponse.Invoke(this, lResponse);
                                PendingResponseQueue.Remove(lUTID);
                            }
                        }
                        catch (Exception) { }
                    }
                }
                OnReciveTokenText(lToken);
            }
            catch (Exception) { }
        }
示例#3
0
文件: Demo.cs 项目: KosBeg/jwebsocket
 private void ListResponse(WebSocketTokenClient sender, TokenResponse e)
 {
     IToken lToken = e.TokenRecive;
     string llist = string.Empty;
     for (int i = 0; i < lToken.GetList("data").Count; i++)
     {
         llist += lToken.GetList("data")[i] + " ";
     }
     listBox1.Items.Add("Recived token [ type:" + lToken.GetType() + " - NS:" + lToken.GetNS() + " - utid:" + lToken.GetInt("utid") + " - data:" + llist + " ]");
 }