Ejemplo n.º 1
0
 protected override bool CheckAuthentication(Context context)
 {
     if (context.ReceivedByteCount > 8)
     {
         var 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 (!String.IsNullOrEmpty(Origin))
             {
                 if (handshake.Origin != "http://" + Origin)
                 {
                     return false;
                 }
             }
             if (!String.IsNullOrEmpty(Destination))
             {
                 if (handshake.Host != Destination + ":" + context.Server.Port.ToString())
                 {
                     return false;
                 }
             }
             // Generate response handshake for the client
             ServerHandshake serverShake = GenerateResponseHandshake(handshake);
             serverShake.SubProtocol = handshake.SubProtocol;
             // Send the response handshake
             SendServerHandshake(serverShake, context);
             return true;
         }
     }
     return false;
 }