private void HandleReadError(Exception e) { if (e is AggregateException) { var agg = e as AggregateException; HandleReadError(agg.InnerException); return; } if (e is ObjectDisposedException) { FleckLog.Debug("Swallowing ObjectDisposedException", e); return; } OnError(e); if (e is HandshakeException) { FleckLog.Debug("Error while reading", e); } else if (e is WebSocketException) { FleckLog.Debug("Error while reading", e); Close(((WebSocketException)e).StatusCode); } else if (e is SubProtocolNegotiationFailureException) { FleckLog.Debug(e.Message); Close(WebSocketStatusCodes.ProtocolError); } else if (e is IOException) { FleckLog.Debug("Error while reading", e); Close(WebSocketStatusCodes.AbnormalClosure); } else { FleckLog.Error("Application Error", e); Close(WebSocketStatusCodes.InternalServerError); } }
public void Start(Action <IWebSocketConnection> config) { var ipLocal = new IPEndPoint(_locationIP, Port); ListenerSocket.Bind(ipLocal); ListenerSocket.Listen(100); FleckLog.Info("Server started at " + Location); if (_scheme == "wss") { if (Certificate == null) { FleckLog.Error("Scheme cannot be 'wss' without a Certificate"); return; } if (EnabledSslProtocols == SslProtocols.None) { EnabledSslProtocols = SslProtocols.Tls; FleckLog.Debug("Using default TLS 1.0 security protocol."); } } ListenForClients(); _config = config; }
private void ListenForClients() { ListenerSocket.Accept(OnClientConnect, e => FleckLog.Error("Listener socket is closed", e)); }