Exemple #1
0
        public void ReceiveMessage(DRP_WebsocketConn wsConn, EventArgs e)
        {
            var thisEndpoint = this;

            // We received data
            WebSocketSharp.MessageEventArgs messageArgs = (WebSocketSharp.MessageEventArgs)e;

            //Console.WriteLine("> " + messageArgs.Data);

            // See what we received
            DRP_MsgIn message = Newtonsoft.Json.JsonConvert.DeserializeObject <DRP_MsgIn>(messageArgs.Data);

            //Console.WriteLine(messageArgs.Data);

            switch (message.type)
            {
            case "cmd":
                thisEndpoint.ProcessCmd(wsConn, message);
                break;

            case "reply":
                thisEndpoint.ProcessReply(wsConn, message);
                break;

            case "stream":
                thisEndpoint.ProcessStream(wsConn, message);
                break;

            default:
                Console.WriteLine("Invalid message.type; here's the JSON data..." + messageArgs.Data);
                break;
            }
        }
Exemple #2
0
 public void ProcessCmd(DRP_WebsocketConn wsConn, DRP_MsgIn message)
 {
     if (message.token != null && message.token.Length > 0)
     {
         //thisEndpoint.SendReply(wsConn, message.token, cmdResults.status, cmdResults.output);
     }
 }
Exemple #3
0
 public void ProcessReply(DRP_WebsocketConn wsConn, DRP_MsgIn message)
 {
     if (wsConn.ReplyHandlerQueue.ContainsKey(message.token))
     {
         // Execute callback
         TaskCompletionSource <object> thisTcs = wsConn.ReplyHandlerQueue[message.token];
         thisTcs.SetResult(message.payload);
         wsConn.ReplyHandlerQueue.Remove(message.token);
     }
     else
     {
         // Bad token
         Console.WriteLine("Received command token with no pending callback -> [{0}]", message.token);
     }
 }
Exemple #4
0
 public void ProcessStream(DRP_WebsocketConn wsConn, DRP_MsgIn message)
 {
 }