internal WebSocketServiceHost(string path, Func <TBehavior> initializer, Logger logger) { _path = path; _initializer = initializer; _logger = logger; _sessions = new WebSocketSessionManager(logger); }
internal void Start(WebSocketContext context, WebSocketSessionManager sessions) { if (_websocket != null) { _websocket.Log.Error("This session has already been started."); context.WebSocket.Close(HttpStatusCode.ServiceUnavailable); return; } _context = context; _sessions = sessions; _websocket = context.WebSocket; _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; _websocket.EmitOnPing = _emitOnPing; _websocket.IgnoreExtensions = _ignoreExtensions; _websocket.Protocol = _protocol; var waitTime = sessions.WaitTime; if (waitTime != _websocket.WaitTime) { _websocket.WaitTime = waitTime; } _websocket.OnOpen += onOpen; _websocket.OnMessage += onMessage; _websocket.OnError += onError; _websocket.OnClose += onClose; _websocket.InternalAccept(); }