public bool CheckHandshake(Context context)
 {
     if(context.ReceivedByteCount > 8)
     {
         ClientHandshake handshake = new ClientHandshake(context.Header);
         // See if our header had the required information
         if (handshake.IsValid())
         {
             // Optionally check Origin and Location if they're set.
             if (Origin != string.Empty)
                 if (handshake.Origin != "http://" + Origin)
                     return false;
             if (Location != string.Empty)
                 if (handshake.Host != Location + ":" + context.Server.Port.ToString())
                     return false;
             // Generate response handshake for the client
             ServerHandshake serverShake = GenerateResponseHandshake(handshake, context);
             serverShake.SubProtocol = handshake.SubProtocol;
             // Send the response handshake
             SendServerHandshake(serverShake, context);
             return true;
         }
     }
     return false;
 }
 private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, Context context)
 {
     ServerHandshake responseHandshake = new ServerHandshake();
     responseHandshake.Accept = GenerateAccept(handshake.Key, context);
     return responseHandshake;
 }
 private static ServerHandshake GenerateResponseHandshake(ClientHandshake AHandshake, Context AContext)
 {
     ServerHandshake AResponseHandshake = new ServerHandshake();
     AResponseHandshake.Accept = GenerateAccept(AHandshake.Key, AContext);
     return AResponseHandshake;
 }