SetProxy() public method

Sets the HTTP proxy server URL to connect through, and if necessary, a pair of username and password for the proxy server authentication (Basic/Digest).
This method is not available in a server.
public SetProxy ( string url, string username, string password ) : void
url string /// /// A that represents the HTTP proxy server URL to /// connect through. The syntax must be http://<host>[:<port>]. /// /// /// If is or empty, /// the url and credentials for the proxy will be initialized, /// and the will not use the proxy to /// connect through. /// ///
username string /// /// A that represents the user name used to authenticate. /// /// /// If is or empty, /// the credentials for the proxy will be initialized and not be sent. /// ///
password string /// A that represents the password for /// used to authenticate. ///
return void
コード例 #1
0
        public WebSocketClient(IMessageInterpreter interpreter, string url, ProxySettings proxySettings)
        {
            _interpreter = interpreter;

            _webSocket = new WebSocket(url);
            _webSocket.OnMessage += WebSocketOnMessage;
            _webSocket.OnClose += (sender, args) => OnClose?.Invoke(sender, args);
            _webSocket.Log.Level = GetLoggingLevel();
            _webSocket.EmitOnPing = true;

            if (proxySettings != null)
            {
                _webSocket.SetProxy(proxySettings.Url, proxySettings.Username, proxySettings.Password);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: tewarid/NetTools
        private void CreateWebSocketClient()
        {
            if (ws != null && ws.IsAlive)
                return;

            ws = new WebSocket(location.Text);

            connect.Enabled = false;
            setHeaders.Enabled = false;
            proxyButton.Enabled = false;
            location.ReadOnly = true;

            ws.SetHeaders(headers);
            ws.SetProxy(proxyUrl, string.Empty, string.Empty);
            ws.OnError += Ws_OnError;
            ws.OnClose += Ws_OnClose;
            ws.OnMessage += Ws_OnMessage;
            ws.OnOpen += Ws_OnOpen;

            ws.Connect();
        }
コード例 #3
0
        private void InitializeInBackground(string url, WebSocketSharp.WebSocket webSocket, JObject options)
        {
            var         parsedOptions = new WebSocketOptions(options);
            ProxyHelper proxy         = null;

            if (parsedOptions.UseDefaultProxy)
            {
                proxy = new ProxyHelper(new Uri(url));
            }
            else
            {
                proxy = new ProxyHelper(parsedOptions);
            }

            if (proxy != null && !proxy.IsBypassed)
            {
                webSocket.SetProxy(proxy.ProxyAddress, proxy.UserName, proxy.Password);
            }

            webSocket.Origin = parsedOptions.Origin;

            webSocket.Connect();
        }