예제 #1
0
        public override void OnMessageReceived(byte[] data, int length, System.Net.WebSockets.WebSocketMessageType type)
        {
            //If this is a binary message, this is always a request to add lines
            if (type == System.Net.WebSockets.WebSocketMessageType.Binary)
            {
                canvas.AddPoints(data, this);
            }
            else if (type == System.Net.WebSockets.WebSocketMessageType.Text)
            {
                //Decode
                IncomingMessage msg = JsonConvert.DeserializeObject <IncomingMessage>(Encoding.UTF8.GetString(data, 0, length));

                //Run action
                switch (msg.opcode)
                {
                case IncomingMessageOpcode.SwitchCanvas: OnCmd_CanvasChange(msg.payload); break;

                case IncomingMessageOpcode.UnsubscribeCanvas: OnCmd_CanvasUnsubscribe(msg.payload); break;

                case IncomingMessageOpcode.ClearCanvas: OnCmd_CanvasClear(msg.payload); break;

                case IncomingMessageOpcode.Ping: OnCmd_Ping(msg.payload); break;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Sends a message to all subscribers
 /// </summary>
 /// <param name="data"></param>
 public void SendMessageToSubscribers(byte[] payload, System.Net.WebSockets.WebSocketMessageType type)
 {
     foreach (var s in subscribers)
     {
         //Send
         s.SendMessage(payload, type);
     }
 }
예제 #3
0
        public override Task OnMessageReceived(ArraySegment <byte> message, System.Net.WebSockets.WebSocketMessageType type)
        {
            //if (response to Read command)
            //{
            //  BytesRead = message;
            //  mutex.ReleaseMutex;
            //}
            //else //new Command
            //{
            Card         c      = new Card();
            RemoteServer server = RemoteServer.Singleton;
            IList <CTSWriteOperation> operations;
            string tkmsg;
            uint   status, result;

            server.RunCommand("id", "", out status, out result, out tkmsg, out operations, c, new ExAPDU(SendRcvMessage));
            //}
            Console.WriteLine(String.Format("Message Received"));

            return(SendText(message, true));
        }
예제 #4
0
 public WebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Net.WebSockets.WebSocketCloseStatus?closeStatus, string?closeStatusDescription)
 {
 }
예제 #5
0
 public WebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage)
 {
 }
예제 #6
0
 public virtual System.Threading.Tasks.ValueTask SendAsync(System.ReadOnlyMemory <byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, System.Net.WebSockets.WebSocketMessageFlags messageFlags, System.Threading.CancellationToken cancellationToken)
 {
     throw null;
 }
예제 #7
0
 public ValueWebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage)
 {
     throw null;
 }
예제 #8
0
 public abstract System.Threading.Tasks.Task SendAsync(System.ArraySegment <byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken);
예제 #9
0
 public override System.Threading.Tasks.Task SendAsync(System.ArraySegment <byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken)
 {
     throw null;
 }
 public override System.Threading.Tasks.ValueTask SendAsync(System.ReadOnlyMemory <byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken)
 {
     throw null;
 }
예제 #11
0
        /*
         * public MyWebSocket ()
         * {
         * }*/

        public override System.Threading.Tasks.Task OnMessageReceived(ArraySegment <byte> message, System.Net.WebSockets.WebSocketMessageType type)
        {
            //Handle the message from the client

            //Example of JSON serialization with the client
            //var json = Encoding.UT8.GetString(message.Array, message.Offset, message.Count);
            //Use something like Json.Net to read the json

            //Handle the message from the client

            //Example of JSON serialization with the client
            var json = System.Text.Encoding.UTF8.GetString(message.Array, message.Offset, message.Count);

            var toSend = System.Text.Encoding.UTF8.GetBytes(json);

            //Echo the message back to the client as text
            return(SendText(toSend, true));
        }