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; } } }
/// <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); } }
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)); }
public WebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Net.WebSockets.WebSocketCloseStatus?closeStatus, string?closeStatusDescription) { }
public WebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage) { }
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; }
public ValueWebSocketReceiveResult(int count, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage) { throw null; }
public abstract System.Threading.Tasks.Task SendAsync(System.ArraySegment <byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, bool endOfMessage, System.Threading.CancellationToken cancellationToken);
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; }
/* * 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)); }