PongWebsocketCommand.cs 505 B

1234567891011121314151617181920
  1. using System;
  2. using System.Net.WebSockets;
  3. using System.Text;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace gameapi.Commands
  7. {
  8. public class PongWebsocketCommand : IWebsocketCommand
  9. {
  10. public PongWebsocketCommand()
  11. {
  12. }
  13. public async Task Run(WebSocket webSocket)
  14. {
  15. await webSocket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes("pong"), 0, 4), WebSocketMessageType.Text, true, CancellationToken.None);
  16. }
  17. }
  18. }