void OnClientConnected(object sender, ClientConnectedEventArgs e) { connection = e.Client; }
void ClientDisconnected(WebSocketConnection sender, EventArgs e) { Connections.Remove(sender); //LogLine(DateTime.Now + "> " + sender.ConnectionSocket.LocalEndPoint + " disconnected", ServerLogLevel.Subtle); }
void DataReceivedFromClient(WebSocketConnection sender, DataReceivedEventArgs e) { /*Log(DateTime.Now + "> data from " + sender.ConnectionSocket.LocalEndPoint, ServerLogLevel.Subtle); * Log(": " + e.Data + "\n" + e.Size + " bytes", ServerLogLevel.Verbose); * LogLine("", ServerLogLevel.Subtle);*/ }
public ClientConnectedEventArgs(WebSocketConnection client) { Client = client; }
private void OnClientDisconnect(WebSocketConnection sender, EventArgs e) { Console.WriteLine("Client disconnected."); }
private void OnClientConnect(IAsyncResult asyn) { try { var client = tcpListener.EndAcceptTcpClient(asyn); Log.InfoFormat("New connection from {0}", client.Client.RemoteEndPoint); ShakeHands(client); var clientConnection = new WebSocketConnection(client.Client); clientConnection.Disconnected += new WebSocketDisconnectedEventHandler(OnClientDisconnect); if (ClientConnected != null) ClientConnected(this, new ClientConnectedEventArgs(clientConnection)); ListenForClients(); } catch (ObjectDisposedException ode) { Log.Info(ode.Message); } }