private static void SendServerHandshake(ServerHandshake handshake, Context context) { // generate a byte array representation of the handshake including the answer to the challenge string temp = handshake.ToString(); byte[] handshakeBytes = Encoding.UTF8.GetBytes(temp); context.UserContext.Send(handshakeBytes, true); }
private static void SendServerHandshake(ServerHandshake handshake, Context context) { // generate a byte array representation of the handshake including the answer to the challenge string temp = handshake.ToString(); byte[] handshakeBytes = Encoding.UTF8.GetBytes(temp); context.UserContext.Send(handshakeBytes, -1, true); }
private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, WebSocketServer server) { var responseHandshake = new ServerHandshake { Accept = GenerateAccept(handshake.Key), Server = server, RequestProtocols = handshake.SubProtocols }; return(responseHandshake); }
private bool CheckAuthenticationResponse(Context context) { var receivedData = context.UserContext.DataFrame.ToString(); var header = new Header(receivedData); var handshake = new ServerHandshake(header); if (Authentication.GenerateAccept(_handshake.Key) != handshake.Accept) return false; if (SubProtocols != null) { if (header.SubProtocols == null) { return false; } foreach (var s in SubProtocols) { if (header.SubProtocols.Contains(s) && String.IsNullOrEmpty(CurrentProtocol)) { CurrentProtocol = s; } } if(String.IsNullOrEmpty(CurrentProtocol)) { return false; } } ReadyState = ReadyStates.OPEN; IsAuthenticated = true; _connecting = false; context.UserContext.OnConnected(); return true; }
private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, WebSocketServer server) { var responseHandshake = new ServerHandshake {Accept = GenerateAccept(handshake.Key), Server = server, RequestProtocols = handshake.SubProtocols}; return responseHandshake; }
private bool CheckAuthenticationResponse(byte[] response) { var receivedData = Encoding.UTF8.GetString(response); var header = new Header(receivedData); var serverHandshake = new ServerHandshake(header); if (AuthenticationServices.GenerateAccept(handshake.Key) != serverHandshake.Accept) return (false); if (SubProtocols != null) { if (header.SubProtocols == null) return (false); foreach (var s in SubProtocols) { if (header.SubProtocols.Contains(s) && String.IsNullOrEmpty(CurrentProtocol)) CurrentProtocol = s; } if (String.IsNullOrEmpty(CurrentProtocol)) return (false); } return true; }