public static void WriteDynamic(this WebSocket ws, dynamic data) { JsonSerializer serializer = new JsonSerializer(); using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) using (var sw = new StreamWriter(writer, Encoding.UTF8)) serializer.Serialize(sw, data); }
public static async Task WriteStringAsync(this WebSocket ws, String data, CancellationToken cancel) { using (var msg = ws.CreateMessageWriter(WebSocketMessageType.Text)) using (var writer = new StreamWriter(msg, Encoding.UTF8)) { writer.Write(data); await writer.FlushAsync().ConfigureAwait(false); } }
public static void WriteString(this WebSocket ws, String data) { using (var msg = ws.CreateMessageWriter(WebSocketMessageType.Text)) using (var writer = new StreamWriter(msg, Encoding.UTF8)) writer.Write(data); }