void IWebSocketListener.OnPong(OkBuffer buffer) { var handler = Pong; if (handler != null) { handler(sender, new PongEventArgs(buffer)); } }
private void StartMessages(IWebSocket webSocket) { // we want to ping every 2 seconds new Timer(state => { var buffer = new OkBuffer(); buffer.WriteString("Ping!", Charset.DefaultCharset()); webSocket.SendPing(buffer); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(2)); // we want to send a message every 5 seconds new Timer(state => { var body = RequestBody.Create(WebSocket.Text, "Hello World!"); webSocket.SendMessage(body); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(3)); }
void IWebSocketListener.OnPong(OkBuffer buffer) { var handler = Pong; if (handler != null) { handler(buffer); } }