internal void OnClientDisconnect(ClientConnectionEventArgs args) { try { if (ClientDisconnected != null) ClientDisconnected(this, args); } finally { if (connections != null && connections.ContainsKey(args.RemoteEndPoint)) { connections.Remove(args.RemoteEndPoint); if (connections.Count == 0) connections = null; } } }
internal bool Connect(bool authorized) { started = DateTime.Now; try { ClientConnectionEventArgs args = new ClientConnectionEventArgs(protocol, LocalEndPoint, remoteEndPoint, authorized); authorized = service.OnClientConnect(args); connected = true; return authorized; } catch (Exception) { connected = false; return false; } }
internal bool OnClientConnect(ClientConnectionEventArgs args) { if (ClientConnected != null) ClientConnected(this, args); return args.Authorized; }
internal void Disconnect() { ClientConnectionEventArgs args = new ClientConnectionEventArgs(protocol, LocalEndPoint, remoteEndPoint, started); try { service.OnClientDisconnect(args); } finally { ended = DateTime.Now; connected = false; } }