SetCredentials() public method

Sets a pair of username and password for the HTTP authentication (Basic/Digest).
This method is not available in a server.
public SetCredentials ( string username, string password, bool preAuth ) : void
username string /// /// A that represents the user name used to authenticate. /// /// /// If is or empty, /// the credentials will be initialized and not be sent. /// ///
password string /// A that represents the password for /// used to authenticate. ///
preAuth bool /// true if the sends the credentials for /// the Basic authentication with the first handshake request to the server; /// otherwise, false. ///
return void
Ejemplo n.º 1
0
        public override object ConstructObject()
        {
            string[] protocols;
            if (FProtocols[this.CurrObj][0] != "")
            {
                protocols = new string[FProtocols[this.CurrObj].SliceCount];
                for (int i = 0; i < FProtocols[this.CurrObj].SliceCount; i++)
                {
                    protocols[i] = FProtocols[this.CurrObj][i];
                }
            }
            else
            {
                protocols = new string[0];
            }

            WebSocketSharp.WebSocket newWebSocket       = new WebSocketSharp.WebSocket(FUrl[this.CurrObj], protocols);
            VebSocketHostedClient    newVebSocketClient = new VebSocketHostedClient(newWebSocket);

            newVebSocketClient.SubscribeToMainloop(this.FHDEHost);

            if (FOrigin[this.CurrObj] != "")
            {
                newWebSocket.Origin = FOrigin[this.CurrObj];
            }

            if (FCookie.IsConnected && (FCookie[this.CurrObj] != null))
            {
                newWebSocket.SetCookie(FCookie[this.CurrObj]);
            }

            if (FServerCertValidCallback.IsConnected && (FServerCertValidCallback[this.CurrObj] != null))
            {
                newWebSocket.SslConfiguration.ServerCertificateValidationCallback = FServerCertValidCallback[this.CurrObj];
            }

            if ((FUser[this.CurrObj] != "") || (FPassword[this.CurrObj] != ""))
            {
                newWebSocket.SetCredentials(FUser[this.CurrObj], FPassword[this.CurrObj], FPreAuth[this.CurrObj]);
            }

            if (FAutoConnect[this.CurrObj])
            {
                newWebSocket.ConnectAsync();
            }

            return(newVebSocketClient);
        }