internal void Start(WebSocketContext context, WebSocketSessionManager sessions) { if (_websocket != null) { _websocket.Log.Error("A session instance cannot be reused."); 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(); }
/// <summary> /// Initializes a new instance of the <see cref="WebSocketServiceHost"/> class /// with the specified <paramref name="path"/> and <paramref name="log"/>. /// </summary> /// <param name="path"> /// A <see cref="string"/> that represents the absolute path to the service. /// </param> /// <param name="log"> /// A <see cref="Logger"/> that represents the logging function for the service. /// </param> protected WebSocketServiceHost(string path, Logger log) { _path = path; _log = log; _sessions = new WebSocketSessionManager(log); }