コード例 #1
0
 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);
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
 }