Example #1
0
 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") + " ]");
 }
        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) { }
        }
Example #3
0
 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 + " ]");
 }