• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# WebSocket4Net.MessageReceivedEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: websocketClient_MessageReceieved

        private void websocketClient_MessageReceieved(object sender, MessageReceivedEventArgs e)
        {
            /* We can let this go away fairly soon, since there's not much we can do in the API Worker anyways
             * at this point. Maybe attach a logger here?
             */
            dynamic data = JsonConvert.DeserializeObject(e.Message);
            switch ((string)data.type)
            {
                case "welcome":
                    Console.WriteLine("API MOTD: " + data.data);
                    break;
                case "assignment":
                    Console.WriteLine("Got a new assignment datafield: " + data.data);
                    break;
                default:
                    Console.WriteLine("Unknown API type field: " + data.type + ": " + data.data);
                    break;
            }

            //appendStatus("Direct parse. Type:" + data.type + " Data:" + data.data);
        }
开发者ID:Amolindk,项目名称:RatTracker,代码行数:21,代码来源:APIWorker.cs


示例17: WebSocket_MessageReceived

        private static void WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var baseEvent = JsonConvert.DeserializeObject<BaseEvent>(e.Message);
            WriteLine($"Message received of type {baseEvent.Type}");

            if (baseEvent.Type == "message")
            {
                var messageEvent = JsonConvert.DeserializeObject<MessageEvent>(e.Message);

                WriteLine(messageEvent.Text);

                var messageCommand = new MessageCommand
                {
                    channel = messageEvent.Channel,
                    text = $"I'm in parrot mode: {messageEvent.Text}"
                };

                webSocket.Send(JsonConvert.SerializeObject(messageCommand));
            }

        }
开发者ID:somecoolname,项目名称:MarvinBot,代码行数:21,代码来源:Program.cs


示例18: handleGame

        private void handleGame(object sender, MessageReceivedEventArgs args)
        {
            oldRoom = Main.ludo.Rooms[ClientBase.roomListSelectionID];
            //Room room = JsonConvert.DeserializeObject<Room>(args.Message);
            Main.ludo = JsonConvert.DeserializeObject<Ludo>(args.Message);
            Room room = Main.ludo.Rooms[ClientBase.roomListSelectionID];

            if (room.RoomID == ClientBase.roomListSelectionID) // affects this my room?
            {
                updatePlayerListBox();
                updateRollTheDiceButton(room);
                if (room.RoomAction.Equals("diceRolled"))
                {
                    printDiceValue(room.Game.DiceValue);
                }
                if (room.Game.MoveCount > 0)
                {
                    updateTheMap(room);
                }
            }
        }
开发者ID:Cir0X,项目名称:ludo,代码行数:21,代码来源:GameHandler.cs


示例19: socket_MessageReceived

        void socket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            //Console.WriteLine(e.Message);

            JObject jObj = JObject.Parse(e.Message);

            if (jObj["msg"] != null)
            {
                switch (jObj["msg"].ToString())
                {
                    case "ping":
                        this.Send("{\"msg\": \"pong\"}");
                        Console.WriteLine("Ping? Pong!");
                        break;

                    default:
                        this._client.DataReceived(jObj);
                        break;
                }

            }
        }
开发者ID:aaronthorp,项目名称:net-meteor-ddp-client,代码行数:22,代码来源:DDPConnector.cs


示例20: MessageReceived

 static void MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     var packet = JArray.Parse(e.Message);
     foreach (var message in packet.Cast<JObject>())
     {
         switch ((string)message["channel"])
         {
             case "/meta/handshake":
                 HandshakeResponse(message);
                 break;
             case "/meta/connect":
                 ConnectRequest();
                 break;
             default:
                 if (((string)message["channel"]).StartsWith("/cloud") || ((string)message["channel"]).StartsWith("/cloud"))
                 {
                     Connection.OnMessageReceived(message);
                 }
                 
                 break;
         }
     }
 }
开发者ID:Conji,项目名称:Cloudsdale-Win7,代码行数:23,代码来源:FayeConnector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebSocket4Net.WebSocket类代码示例发布时间:2022-05-26
下一篇:
C# CommonLibrary.DataConnection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap