private void SocketMessage(object sender, SocketIOClient.MessageEventArgs e)
 {
     if (e != null && e.Message != null)
     {
         IDictionary search = (IDictionary)Json.Deserialize(e.Message.MessageText);
         if (search != null)
         {
             if (String.Equals(search["name"], "msg"))
             {
                 frameList.Add(new Frame((IList)search["args"]));
                 lastindex++;
                 lastlastindex = lastindex - 1;
                 frameIndex    = 0;
             }
             else if (String.Equals(search["name"], "new player"))
             {
                 IList hashedIds = (IList)search["args"];
                 Debug.Log(e.Message.MessageText);
                 playersArray.Add(new NPlayer(hashedIds[0].ToString(), objCreate));
             }
             else if (String.Equals(search["name"], "remove player"))
             {
                 IList hashedId = (IList)search["args"];
                 foreach (NPlayer player in playersArray)
                 {
                     if (String.Equals(player.id, hashedId))
                     {
                         playersArray.Remove(player);
                         break;
                     }
                 }
             }
         }
     }
 }
 private void SocketMessage(object sender, SocketIOClient.MessageEventArgs e)
 {
     if (e != null)
     {
         Debug.Log("Socket Receive Message : " + e.Message);
     }
 }
		void SocketMessage(object sender, MessageEventArgs e)
		{
			// uncomment to show any non-registered messages
			//if (string.IsNullOrEmpty(e.Message.Event))
			//    Console.WriteLine("Generic SocketMessage: {0}", e.Message.MessageText);
			//else
			//    Console.WriteLine("Generic SocketMessage: {0} : {1}", e.Message.Event, e.Message.JsonEncodedMessage.ToJsonString());
		}
        void socketIO_Message(object sender, MessageEventArgs e)
        {
            if ("hStatus".Equals(e.Message.Event, StringComparison.OrdinalIgnoreCase))
            {
                if (e.Message.Json.Args != null)
                {
                    JObject data = (JObject)e.Message.Json.Args[0];
                    try
                    {
                        HStatus status = new HStatus(data);
                        if (connTimeoutTimer != null)
                        {
                            connTimeoutTimer.Cancel();
                            connTimeoutTimer = null;
                        }
                        if (status.GetStatus().Value == ConnectionStatus.CONNECTED)
                        {
                            if (isFullJidSet)
                                updateStatus((ConnectionStatus)status.GetStatus(), (ConnectionErrors)status.GetErrorCode(), status.GetErrorMsg());
                        }
                        else
                            updateStatus((ConnectionStatus)status.GetStatus(), (ConnectionErrors)status.GetErrorCode(), status.GetErrorMsg());
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("{0} : {0} exception caught.", ex);
                        if (connTimeoutTimer != null)
                        {
                            connTimeoutTimer.Cancel();
                            connTimeoutTimer = null;
                        }
                        socketIO.Close();
                        updateStatus(ConnectionStatus.DISCONNECTED, ConnectionErrors.TECH_ERROR, ex.Message);
                    }
                }

            }
            else if("hMessage".Equals(e.Message.Event, StringComparison.OrdinalIgnoreCase))
            {
                if (e.Message.Json.Args != null)
                {
                    JObject data = (JObject)e.Message.Json.Args[0];
                    try
                    {
                        if (connTimeoutTimer != null)
                        {
                            connTimeoutTimer.Cancel();
                            connTimeoutTimer = null;
                        }
                        onData(e.Message.Json.Name, data);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("{0} : {0} exception caught.", ex);
                        if (connTimeoutTimer != null)
                        {
                            connTimeoutTimer.Cancel();
                            connTimeoutTimer = null;
                        }
                    }
                }
            }
            else if ("attrs".Equals(e.Message.Event, StringComparison.OrdinalIgnoreCase))
            {
                if (e.Message.Json.Args != null)
                {
                    JObject data = (JObject)e.Message.Json.Args[0];
                    try
                    {
                        options.FullUrn = data["publisher"].ToString();
                        isFullJidSet = true;
                        if (connStatus != ConnectionStatus.CONNECTED)
                            updateStatus(ConnectionStatus.CONNECTED, ConnectionErrors.NO_ERROR, null);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("{0} : {0} exception caught.", ex);
                    }

                }
            }
        }
 void socketIO_Message(object sender, MessageEventArgs e)
 {
     if (string.IsNullOrEmpty(e.Message.Event))
     {
         Debug.WriteLine("--> SOCKET_IO_MESSAGE:: {0}", e.Message.MessageText);
     }
     else
     {
         Debug.WriteLine("--> SOCKET_IO_MESSAGE:: {0} : {1}", e.Message.Event, e.Message.Json.ToJsonString());
         //screenTbk.Text += e.Message.Json.ToJsonString();
     }
 }
 /// <summary>
 /// When message from server comes, it invoke.
 /// </summary>
 /// <param name='sender'>
 /// Sender.
 /// </param>
 /// <param name='e'>
 /// E.
 /// </param>
 private void SocketMessage(object sender, MessageEventArgs e)
 {
     if ( e!= null && e.Message.Event == "message") {
         string msg = e.Message.MessageText;
         if (msg.IndexOf(ARRAY_FLAG) == 0) {
             this.processMessageBatch(msg);
         } else {
             this.processMessage(msg);
         }
     }
 }
Exemple #7
0
 void client_Message(object sender, MessageEventArgs e)
 {
     if (e.Message.MessageText != null)
     {
         JObject obj = JObject.Parse(e.Message.MessageText);
         if(obj["name"].Value<string>().Trim('\"') == "request"){
             var args = obj["args"].Values<string>().ToList();
             var items = args[0].Trim('\"');
             SendCommand(items);
         }
     }
 }
Exemple #8
0
 private void SocketClientMessage(object sender, MessageEventArgs args)
 {
     if (args.Message.MessageText != null)
     {
         LastMessage = DateTime.Now;
         JContainer o = (JContainer)JsonConvert.DeserializeObject(args.Message.MessageText);
         string op = o["op"].Value<string>();
         if (op == "remark")
             return;
         string channel = o["channel"].Value<string>();
         if (op.Equals("private"))
         {
             switch (channel)
             {
                 case TickerChannel:
                     Mediator.Instance.NotifyColleagues("Ticker", new Ticker(JsonConvert.DeserializeObject<MtGoxTicker>(o["ticker"].ToString())));
                     break;
                 case TradesChannel:
                     Mediator.Instance.NotifyColleagues("Trade", JsonConvert.DeserializeObject<Trade>(o["trade"].ToString()));
                     break;
                 case DepthChannel:
                     Mediator.Instance.NotifyColleagues("DepthUpdate", JsonConvert.DeserializeObject<DepthUpdate>(o["depth"].ToString()));
                     break;
                 case LagChannel:
                     if ((long)o["lag"]["age"] == 0 || (o["lag"]["qid"] == null && o["lag"]["stamp"] == null))
                         Mediator.Instance.NotifyColleagues("Lag", new LagChannelResponse{age = 0, qid = new Guid(), stamp = DateTime.Now});
                     else
                         Mediator.Instance.NotifyColleagues("Lag", JsonConvert.DeserializeObject<LagChannelResponse>(o["lag"].ToString()));
                     break;
                 default:
                     if (channel == OrderChannel)
                     {
                         if (o["private"].Value<String>().Equals("wallet"))
                         {
                             Mediator.Instance.NotifyColleagues("Wallet", JsonConvert.DeserializeObject<WalletResponse>(o["wallet"].ToString()));
                         }
                         else if (o["private"].Value<String>().Equals("user_order"))
                         {
                             Mediator.Instance.NotifyColleagues("Order", JsonConvert.DeserializeObject<Order>(o["user_order"].ToString()));
                         }
                     }
                     break;
             }
         }
         else
         {
             if (op == "subscribe" && channel != TickerChannel && channel != TradesChannel && channel != DepthChannel && channel != LagChannel)
                 OrderChannel = channel;
         }
     }
 }
Exemple #9
0
 void SocketMessage(object sender, MessageEventArgs e)
 {
     Console.WriteLine("SocketMessage {0}", e.Message.RawMessage);
 }
Exemple #10
0
 void _client_Message(object sender, MessageEventArgs e)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
 static void socket_Message(object sender, MessageEventArgs e)
 {
     if (e.Message.Event == "open")
         socket.Emit("provider", "o hai there. got some data for youz");
     else if (e.Message.Event == "provided")
         driver.OpenConnection();
     else if (e.Message.Event == "start")
     {
         driver.SendCommand(new PidRequest() { Guid = Guid.NewGuid(), Pids = new OBDPid[] { OBDPid.Elm327Initialize } });
         driver.Elm327DataRecieved += driver_Elm327DataRecieved;
     }
     else if (e.Message.Event == "stop")
     {
         monitors.ForEach(m => m.Stop());
         driver.CloseConnection();
     }
 }
Exemple #12
0
    private void SocketMessage(object sender, SocketIOClient.MessageEventArgs e)
    {
        if (e != null && e.Message.Event == "message")
        {
            string msg = e.Message.MessageText;
            //uiMessage += "Success: "+msg+"\n";

            if (!tryLogin)
            {
                return;
            }

            var node = SimpleJSON.JSON.Parse(msg);

            if (node["type"].Value == "PlayerJoin")
            {
                var data = node["data"];

                string[] position  = data["position"].ToString().Replace("\"", "").Split(';');
                Player   tmpPlayer = new Player(data["name"],
                                                new Vector3(
                                                    float.Parse(position[0]),
                                                    float.Parse(position[1]),
                                                    float.Parse(position[2]))
                                                );

                playersToAdd.Add(tmpPlayer);
            }

            if (node["type"].Value == "PlayerLogin")
            {
                var data = node["data"];

                string[] position  = data["position"].ToString().Replace("\"", "").Split(';');
                Player   tmpPlayer = new Player(data["name"],
                                                new Vector3(
                                                    float.Parse(position[0]),
                                                    float.Parse(position[1]),
                                                    float.Parse(position[2]))
                                                );

                updatePosition = tmpPlayer.Position;
                moveToPosition = updatePosition;

                JSONArray otherPLayers = data["players"].AsArray;
                foreach (var objJSON in otherPLayers.Childs)
                {
                    string[] othPosition = objJSON["position"].ToString().Replace("\"", "").Split(';');
                    Player   othPlayer   = new Player(objJSON["name"],
                                                      new Vector3(
                                                          float.Parse(othPosition[0]),
                                                          float.Parse(othPosition[1]),
                                                          float.Parse(othPosition[2]))
                                                      );

                    playersToAdd.Add(othPlayer);
                }

                playersToAdd.Add(tmpPlayer);
                return;
            }

            if (node["type"].Value == "PlayerUpdate")
            {
                var data = node["data"];

                if (allPlayers.ContainsKey(data["name"]))
                {
                    string[] position = data["position"].Value.Split(';');
                    updatePosition = new Vector3(
                        float.Parse(position[0]),
                        float.Parse(position[1]),
                        float.Parse(position[2])
                        );
                    moveToPosition = updatePosition;
                }
            }

            if (node["type"].Value == "PlayerDisconnect")
            {
                var data = node["data"];

                if (allPlayers.ContainsKey(data["name"]))
                {
                    allPlayers[data["name"]].canKill = true;
                }
            }
        }
    }
 static void socket_OnMessage(object sender, MessageEventArgs e)
 {
     if (log.IsDebugEnabled) { log.Debug("SendEvent.SocketMessage." + e.Message.JsonEncodedMessage.ToJsonString()); }
     //string s = e.Message.MessageText;
 }
        protected void socket_OnMessage(object sender, MessageEventArgs e)
        {
            if (e.Message == null)
            {
                if (log.IsDebugEnabled) { log.Debug("socket_Error.e." + e.ToString()); }

                Console.WriteLine("\r\nSocketIoProxy.Message: {0}", e.ToString());
            }
            else
            {
                if (log.IsDebugEnabled) { log.Debug("socket_Error.eMessage." + e.Message.JsonEncodedMessage.ToJsonString()); }

                Console.WriteLine("\r\nSocketIoProxy.Message: {0} : {1}", e.Message.Event, e.Message.JsonEncodedMessage.ToJsonString());
            }
        }
 static void socket_Message(object sender, MessageEventArgs e)
 {
     //Console.WriteLine("received something: " + e.Message.MessageText);
 }
Exemple #16
0
 private static void SocketMessage(object sender, MessageEventArgs e)
 {
 }
Exemple #17
0
        private void SocketClientMessage(object sender, MessageEventArgs args)
        {
            if (args.Message.MessageText != null)
            {

            }
        }