Beispiel #1
0
 public static Socket.Options FromURI(Uri uri, Socket.Options opts)
 {
     if (opts == null)
     {
         opts = new Socket.Options();
     }
     opts.Host   = uri.Host;
     opts.Secure = uri.Scheme == "https" || uri.Scheme == "wss";
     opts.Port   = uri.Port;
     if (!string.IsNullOrEmpty(uri.Query))
     {
         opts.QueryString = uri.Query;
     }
     return(opts);
 }
Beispiel #2
0
        public Socket(Socket.Options options)
        {
            if (options.Host != null)
            {
                string[] strArray = options.Host.Split(':');
                options.Hostname = strArray[0];
                if (strArray.Length > 1)
                {
                    options.Port = int.Parse(strArray[strArray.Length - 1]);
                }
            }

            this.Secure   = options.Secure;
            this.Hostname = options.Hostname;
            this.Port     = options.Port;
            this.Query    = options.QueryString != null?ParseQS.Decode(options.QueryString) : new Dictionary <string, string>();

            if (options.Query != null)
            {
                foreach (KeyValuePair <string, string> keyValuePair in options.Query)
                {
                    this.Query.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            this.Upgrade           = options.Upgrade;
            this.Path              = (options.Path ?? "/engine.io").Replace("/$", "") + "/";
            this.TimestampParam    = options.TimestampParam ?? "t";
            this.TimestampRequests = options.TimestampRequests;
            this.Transports        = options.Transports ?? ImmutableList <string> .Empty.Add(Polling.NAME).Add(WebSocket.NAME);

            this.PolicyPort      = options.PolicyPort != 0 ? options.PolicyPort : 843;
            this.RememberUpgrade = options.RememberUpgrade;
            this.Cookies         = options.Cookies;
            if (options.IgnoreServerCertificateValidation)
            {
                ServerCertificate.IgnoreServerCertificateValidation();
            }
            this.ExtraHeaders = options.ExtraHeaders;
        }
Beispiel #3
0
 public Socket(Uri uri, Socket.Options options)
     : this(uri == (Uri)null ? options : Socket.Options.FromURI(uri, options))
 {
 }
Beispiel #4
0
 public Socket(string uri, Socket.Options options)
     : this(uri == null ? (Uri)null : Socket.String2Uri(uri), options)
 {
 }