/// <summary> /// Sends the specified data. /// </summary> /// <param name="aString">The data.</param> /// <param name="raw">whether or not to send raw data</param> public void Send(String aString, bool raw = false) { var bytes = Encoding.UTF8.GetBytes(aString); if (raw) { Context.Handler.Send(bytes, Context); } else { DataFrame dataFrame = new DataFrame(bytes, WebSocketOpCode.Text); Context.Handler.Send(dataFrame, Context); } }
/// <summary> /// Sends the specified data. /// </summary> /// <param name="someBytes">The data.</param> /// <param name="raw">whether or not to send raw data</param> /// <param name="close">if set to <c>true</c> [close].</param> public void Send(byte[] someBytes, bool raw = false) { if (raw) { Context.Handler.Send(someBytes, Context); } else { var dataFrame = new DataFrame(someBytes, WebSocketOpCode.Binary); Context.Handler.Send(dataFrame, Context, raw); } }
/// <summary> /// Called when [receive]. /// </summary> public void OnReceive(DataFrame frame) { OnReceiveDelegate(this, frame); }
/// <summary> /// Sends the specified data. /// </summary> /// <param name="dataFrame">The data.</param> /// <param name="raw">Whether or not to send raw data</param> /// <param name="close">if set to <c>true</c> [close].</param> public void Send(DataFrame dataFrame, bool close = false) { Context.Handler.Send(dataFrame, Context, close); }
/// <summary> /// Sends the specified data. /// </summary> /// <param name="someBytes">The data.</param> /// <param name="raw">whether or not to send raw data</param> /// <param name="close">if set to <c>true</c> [close].</param> public void Send(byte[] someBytes, bool raw = false) { if (raw) { Context.Connection.Client.Send(someBytes); } else { var dataFrame = new DataFrame(someBytes, WebSocketOpCode.Binary); Context.Connection.Client.Send(dataFrame.ToBytes()); } }
/// <summary> /// Sends the specified data. /// </summary> /// <param name="aString">The data.</param> /// <param name="raw">whether or not to send raw data</param> public void Send(String aString, bool raw = false) { var bytes = Encoding.UTF8.GetBytes(aString); if (raw) { Context.Connection.Client.Send(bytes); } else { DataFrame dataFrame = new DataFrame(bytes, WebSocketOpCode.Text); Context.Connection.Client.Send(bytes); } }
/// <summary> /// Sends the specified data. /// </summary> /// <param name="dataFrame">The data.</param> /// <param name="raw">Whether or not to send raw data</param> /// <param name="close">if set to <c>true</c> [close].</param> public void Send(DataFrame dataFrame, bool close = false) { Context.Connection.Client.Send(dataFrame.ToBytes()); }
private void OnReceiveCore(UserContext context, DataFrame frame) { var memoryStream = new MemoryStream(); memoryStream.Write(frame.Payload, 0, frame.Payload.Length); memoryStream.Position = 0; var obj = JsonSerializer.Parse<JukeboxMessage>(memoryStream); JukeboxMessage dispatcherObject = (JukeboxMessage)obj; if (dispatcherObject.Type == "response") HandleResponse(dispatcherObject); else if (dispatcherObject.Type == "request") HandleRequest(dispatcherObject); else if (dispatcherObject.Type == "error") HandleError(dispatcherObject); }
private void OnReceive(UserContext context, DataFrame frame) { try { OnReceiveCore(context, frame); } catch (Exception e) { ts.TraceEvent(TraceEventType.Error, 0, e.Message); } }