当前位置: 首页>>代码示例>>C#>>正文


C# WebSocket4Net.MessageReceivedEventArgs类代码示例

本文整理汇总了C#中WebSocket4Net.MessageReceivedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# MessageReceivedEventArgs类的具体用法?C# MessageReceivedEventArgs怎么用?C# MessageReceivedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageReceivedEventArgs类属于WebSocket4Net命名空间,在下文中一共展示了MessageReceivedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: websocket_MessageReceived

 /// <summary>
 /// Handles the MessageReceived event of the websocket control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MessageReceivedEventArgs"/> instance containing the event data.</param>
 void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (OnReceiveDelegate != null)
     {
         OnReceiveDelegate(Encoding.UTF8.GetBytes(e.Message));
     }
 }
开发者ID:rrb008,项目名称:MediaBrowser.ApiClient,代码行数:12,代码来源:WebSocket4NetClientWebSocket.cs

示例2: _socket_MessageReceived

 void _socket_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (! _handle_Ping(e.Message))
     {
         this._client.AddItem(e.Message);
     }
 }
开发者ID:bbqchickenrobot,项目名称:DDPClient.NET,代码行数:7,代码来源:DDPConnector.cs

示例3: websocket_MessageReceived

 /// <summary>
 /// Handles the MessageReceived event of the websocket control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MessageReceivedEventArgs"/> instance containing the event data.</param>
 void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (OnReceiveDelegate != null)
     {
         OnReceiveDelegate(e.Message);
     }
 }
开发者ID:bartonnen,项目名称:MediaBrowser.Classic,代码行数:12,代码来源:WebSocket4NetClientWebSocket.cs

示例4: OnMessageReceived

        private async void OnMessageReceived(object sender, MessageReceivedEventArgs args)
        {
            if (OnData == null) return;

            var exceptionOccured = false;
            try
            {
                var text = args.Message;
                OnData(sender, new DataReceivedEventArgs { TextData = text });
            }
            catch (Exception)
            {
                exceptionOccured = true;
            }
            // cannot await in catch
            if (exceptionOccured)
            {
                _connectionState = ConnectionState.Failed;
                try
                {
                    await Reconnect();
                }
                catch (Exception e)
                {
                    Error(e);
                }
            }
        }
开发者ID:luiseduardohdbackup,项目名称:Pusher.NET,代码行数:28,代码来源:WebSocketConnection.cs

示例5: websocket_MessageReceived

        protected override void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            base.websocket_MessageReceived(sender, e);
            try
            {
                BinResponce res = JsonHelper.JsonToObject(typeof(BinResponce), null, e.Message) as BinResponce;

                switch (res.code)
                {
                    case 100:
                        {
                            mainPage.Dispatcher.BeginInvoke(new Action(() => {
                                mainPage.GotoOnlinePage();
                            }));
                            break;
                        }
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                ;
            }
        }
开发者ID:reeonce,项目名称:CrazyParty,代码行数:25,代码来源:LiarDiceGameHelper.cs

示例6: ws_MessageReceived

 static void ws_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     System.Threading.Interlocked.Increment(ref backCount);
     if (backCount == count)
     {
         Console.WriteLine((DateTime.Now - dt));
     }
 }
开发者ID:Indifer,项目名称:Test,代码行数:8,代码来源:Program.cs

示例7: doLogin

 /// <summary>
 /// An auto-login handler which is only raised once.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void doLogin(object sender, MessageReceivedEventArgs e)
 {
     socket.MessageReceived -= doLogin;
     send("login", new {
         username = email,
         password = pass,
         userAgent = ua
     });
 }
开发者ID:fleetfreedom,项目名称:WhiteWhale,代码行数:14,代码来源:Program.cs

示例8: m_WebSocket_MessageReceived

        void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            AppendText("Received:" + e.Message);

            if (e.Message.Equals(m_CurrentSendMessage))
                AppendText("Receive correct");
            else
                AppendText("Receive error");

            m_WebSocket.Close();
        }
开发者ID:screws0ft,项目名称:WebSocket4Net,代码行数:11,代码来源:MainPage.xaml.cs

示例9: receiveChat

 public void receiveChat(object sender, MessageReceivedEventArgs args)
 {
     ludo_client.dto.Message newIncomingMessage = JsonConvert.DeserializeObject<ludo_client.dto.Message>(args.Message);
     if (newIncomingMessage.TargetRoomID != Main.ludo.Users[ClientBase.myUserListIndex].CurrentRoomID)
     {
         updateMessageList(this.messageList, newIncomingMessage); // for global server chat
     }
     else
     {
         updateMessageList(this.roomMessageList, newIncomingMessage); // for room chat
     }
 }
开发者ID:Cir0X,项目名称:ludo,代码行数:12,代码来源:ChatHandler.cs

示例10: btc_MessageReceived

        static void btc_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            int eioMessageType = -1;
            if (int.TryParse(e.Message.Substring(0, 1), out eioMessageType))
            {
                switch ((engineioMessageType)eioMessageType)
                {
                    case engineioMessageType.PING:
                        //replace incoming PING with PONG in incoming message and resend it.
                        btc.Send(string.Format("{0}{1}", (int)engineioMessageType.PONG, e.Message.Substring(1, e.Message.Length - 1)));
                        break;
                    case engineioMessageType.PONG:
                        pong = true;
                        break;

                    case engineioMessageType.MESSAGE:
                        int sioMessageType = -1;
                        if (int.TryParse(e.Message.Substring(1, 1), out sioMessageType))
                        {
                            switch ((socketioMessageType)sioMessageType)
                            {
                                case socketioMessageType.CONNECT:
                                    //Send "42["subscribe",["marketdata_cnybtc","marketdata_cnyltc","marketdata_btcltc"]]"
                                    btc.Send(string.Format("{0}{1}{2}", (int)engineioMessageType.MESSAGE,
                                                                       (int)socketioMessageType.EVENT,
                                                                       "[\"subscribe\",[\"marketdata_cnybtc\",\"marketdata_cnyltc\",\"marketdata_btcltc\"]]"));
                                    break;
                                case socketioMessageType.EVENT:
                                    if (e.Message.Substring(4, 5) == "trade")//listen on "trade"
                                        Console.WriteLine(e.Message.Substring(e.Message.IndexOf('{'), e.Message.LastIndexOf('}') - e.Message.IndexOf('{') + 1));
                                    break;
                                default:
                                    Console.WriteLine("error switch socket.io messagetype:" + e.Message);
                                    break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("error parse socket.io messagetype!");
                        }
                        break;

                    default:
                        Console.WriteLine("error switch engine.io messagetype");
                        break;
                }
            }
            else
            {
                Console.WriteLine("error parsing engine.io messagetype!");
            }
        }
开发者ID:BTCChina,项目名称:btcchina-api-csharp,代码行数:52,代码来源:Program.cs

示例11: receiveThisUserObject

 private void receiveThisUserObject(object sender, MessageReceivedEventArgs args)
 {
     var jsonString = JsonConvert.DeserializeObject<User>(args.Message);
     int userListIndex = jsonString.UserListIndex;
     this.user = JsonConvert.DeserializeObject<User>(args.Message); // receiving my user object
     Main.ludo.Users[0] = this.user;
     if (isUserNameAvailable())
     {
         ClientBase.myUserListIndex = userListIndex;
     }
     else
     {
         MessageBox.Show("Username is already used");
     }
 }
开发者ID:Cir0X,项目名称:ludo,代码行数:15,代码来源:AuthenticationHandler.cs

示例12: receive

        public void receive(object sender, MessageReceivedEventArgs e)
        {
            Console.WriteLine(e.Message);
            JObject json = JObject.Parse(e.Message);
            if (json.GetValue("result").ToString() != "success") return;
            string src = json.GetValue("source").ToString();
            switch (src)
            {
                case "getPlayerLimit":
                    MessageBox.Show("The actual Player limit is: " + json.GetValue("success").ToString());
                    break;
                case "getPlayerNames":
                    clear x = new clear(clearbox);
                    this.Invoke(x);
                    JToken token = json.GetValue("success");
                    foreach (JToken f in token)
                    {
                        add c = new add(addbox);
                        this.Invoke(c, f.ToString());

                    }

                    break;
                case "getPlayer":
                    JToken pos = json.GetValue("success").SelectToken("location");
                    string posi =  "x: " + pos.SelectToken("x").ToString() + " y: " + pos.SelectToken("y").ToString() + " z: " + pos.SelectToken("z").ToString();
                    string op = Convert.ToString(json.GetValue("success").SelectToken("op"));
                    string world = json.GetValue("success").SelectToken("worldInfo").SelectToken("name").ToString();
                    string gamemode = json.GetValue("success").SelectToken("gameMode").ToString();
                    infoHandler handler = new infoHandler(addinfo);
                    this.Invoke(handler, posi, world, op, gamemode);
                    break;
                case "kickPlayer":
                    if (!mk)
                    MessageBox.Show("Player gekickt");
                    break;
                case "opPlayer":
                    MessageBox.Show("Player is OP.");
                    break;
                case "deopPlayer":
                    MessageBox.Show("Player is no longer OP");
                    break;
                default:
                    Console.WriteLine(e.Message);
                    break;
            }
        }
开发者ID:Railcrafti,项目名称:ModernMinasServer,代码行数:47,代码来源:Form1.cs

示例13: websocket_MessageReceived

        private void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            //Trace.WriteLine(e.Message);
            if (e.Message.Equals("1::")) return;
            if (e.Message.Equals("2::"))
            {
                _websocket.Send("2::");
                return;
            }
            if (e.Message.StartsWith("5:::"))
            {
                var jsonObj = JObject.Parse(e.Message.Substring(4));
                var args = JObject.Parse(jsonObj.GetValue("args").First.ToString());
                var method = args.GetValue("method");
                var paramsObject = args.GetValue("params");

                switch (method.ToString())
                {
                    case "loginMsg":
                        GuiMessage(hb.Username, "SYSTEM: Successfully connected to server.", "000000");
                        SendUserListMessage();
                        break;

                    case "chatMsg":
                        GuiMessage(paramsObject["name"].ToString(), paramsObject["text"].ToString(),
                            paramsObject["nameColor"].ToString());
                        break;
                    case "userList":
                        UserListThread = new Thread(() => { hb.LoadUserData(paramsObject.ToString()); });
                        UserListThread.Start();
                        break;
                    case "banList":
                        BanListThread = new Thread(() => { hb.LoadBanList(paramsObject.ToString()); });
                        BanListThread.Start();
                        break;
                    default:
                        return;
                }
                //Debug.WriteLine(jsonObj);
                //Debug.WriteLine("jsonObj: {0}", jsonObj);
                //Debug.WriteLine("test: {0}", args);
                //Debug.WriteLine("method: {0}", method);
                //Debug.WriteLine("Params: {0}", paramsObject);
            }
        }
开发者ID:Hitakashi,项目名称:HitboxDashboard-WPF,代码行数:45,代码来源:WebSocketData.cs

示例14: MessageReceived

        private void MessageReceived(object s, MessageReceivedEventArgs e)
        {
            QuoteMessage message = null;

            try
            {
                message = JsonConvert.DeserializeObject<QuoteMessage>(e.Message);
            }
            catch (Exception ex)
            {
                ErrorOccured(this, ex.Message);
            }

            if (message != null && message.Ok && message.Quote != null && QuoteReceived != null)
            {
                QuoteReceived(this, message.Quote);
            }
        }
开发者ID:pb8,项目名称:Stockfighter,代码行数:18,代码来源:QuotesFeed.cs

示例15: webSocket_MessageReceived

        void webSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var obj = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(e.Message);

            //var obj = new JsonObject();
            //obj.
            if (obj == null) {
                return;
            }

            var tele = new Telemetry();
            tele.Name = (string)obj ["Name"];
            tele.SourceId = Int32.Parse(obj["SourceId"].ToString());
            tele.Value = float.Parse(obj["Value"].ToString());
            tele.Timestamp = DateTime.Parse((string)obj["TimeStamp"]);

            Database.Main.InsertTelemetryAsync(tele);

            Console.WriteLine(e.Message.ToString());
        }
开发者ID:Clancey,项目名称:Grapher,代码行数:20,代码来源:TelemetryService.cs


注:本文中的WebSocket4Net.MessageReceivedEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。