public void CreateHandler(IEnumerable <byte> data) { var request = _parseRequest(data.ToArray()); if (request == null) { return; } Handler = _handlerFactory(request); if (Handler == null) { return; } var subProtocol = _negotiateSubProtocol(request.SubProtocols); ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort, subProtocol); _initialize(this); var handshake = Handler.CreateHandshake(subProtocol); Send(handshake, "handshake", OnOpen); }
public bool CreateHandler(ArraySegment <byte> data) { var request = _parseRequest(data); if (request == null) { return(false); } Handler = _handlerFactory(this, request); if (Handler == null) { return(false); } ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort); _initialize(this); var handshake = Handler.CreateHandshake(); SendBytes(handshake, (instance, success) => { if (success) { instance.OnOpen(); } }); return(true); }
public void CreateHandler(IEnumerable <byte> data) { var request = _parseRequest(data.ToArray()); if (request == null) { return; } Handler = _handlerFactory(request); if (Handler == null) { return; } ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort); _initialize(this); var handshake = Handler.CreateHandshake(); SendBytes(handshake, OnOpen); }