//メッセージ受信
        static void HandleServerNewMessageReceived(SuperSocket.WebSocket.WebSocketSession session,
                                                   string e)
        {
            frm.Invoke((MethodInvoker) delegate()
            {
                MessageData recv = JsonConvert.DeserializeObject <MessageData>(e);

                switch (recv.command)
                {
                case "send_command":

                    frm.Invoke((MethodInvoker) delegate()
                    {
                        var send_txt = recv.message;

                        if (!frm.serialPort1.IsOpen)
                        {
                            frm.serialPort1.Open();
                        }
                        frm.serialPort1.Write(send_txt);
                        frm.add_log(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "送信:" + send_txt);
                    });

                    break;

                case "end_capture":

                    break;
                }
            });
        }
        static void HandleServerNewSessionConnected(SuperSocket.WebSocket.WebSocketSession session)
        {
            frm.session_ary.Add(session.SessionID, session);

            frm.Invoke((MethodInvoker) delegate()
            {
                frm.add_log(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "接続");
            });
        }
        //切断
        static void HandleServerSessionClosed(SuperSocket.WebSocket.WebSocketSession session,
                                              SuperSocket.SocketBase.CloseReason e)
        {
            if (frm != null)
            {
                frm.session_ary.Remove(session.SessionID);

                frm.Invoke((MethodInvoker) delegate()
                {
                    frm.add_log(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "切断");
                });
            }
        }
Beispiel #4
0
        //メッセージ受信
        static void HandleServerNewMessageReceived(SuperSocket.WebSocket.WebSocketSession session,
                                                   string e)
        {
            frm.Invoke((MethodInvoker) delegate()
            {
                MessageData recv = JsonConvert.DeserializeObject <MessageData>(e);

                switch (recv.command)
                {
                case "add_message_to_app":

                    frm.add_log(recv.time, "受信: " + recv.message);

                    break;
                }
            });
        }