public Uri HttpToWs(Uri httpUri, SocketIOOptions options)
        {
            var builder = new StringBuilder();

            if (httpUri.Scheme == "https" || httpUri.Scheme == "wss")
            {
                builder.Append("wss://");
            }
            else
            {
                builder.Append("ws://");
            }
            builder.Append(httpUri.Host);
            if (!httpUri.IsDefaultPort)
            {
                builder.Append(":").Append(httpUri.Port);
            }
            builder
            .Append(options.Path)
            .Append("/?EIO=3&transport=websocket");

            if (options.Query != null)
            {
                foreach (var item in options.Query)
                {
                    builder
                    .Append("&")
                    .Append(item.Key)
                    .Append("=")
                    .Append(item.Value);
                }
            }
            return(new Uri(builder.ToString()));
        }
Exemplo n.º 2
0
 public SocketIO(Uri uri, SocketIOOptions options)
 {
     ServerUri    = uri;
     UrlConverter = new UrlConverter();
     _options     = options;
     //Socket = new WebSocketClient.WebSocketClient(this, new PackgeManager(this));
     Socket = new ClientWebSocket(this, new PackgeManager(this));
     if (uri.AbsolutePath != "/")
     {
         Namespace = uri.AbsolutePath + ',';
     }
     PacketId            = -1;
     Acks                = new Dictionary <int, Action <SocketIOResponse> >();
     Handlers            = new Dictionary <string, Action <SocketIOResponse> >();
     OutGoingBytes       = new List <byte[]>();
     _byteArrayConverter = new ByteArrayConverter
     {
         Client = this
     };
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create SocketIO object with default options
 /// </summary>
 public SocketIO()
 {
     Options = new SocketIOOptions();
     Initialize();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create SocketIO object with options
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="options"></param>
 public SocketIO(Uri uri, SocketIOOptions options)
 {
     ServerUri = uri;
     Options   = options;
     Initialize();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create SocketIO object with options
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="options"></param>
 public SocketIO(string uri, SocketIOOptions options) : this(new Uri(uri), options)
 {
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create SocketIO object with options
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="options"></param>
 public SocketIO(Uri uri, SocketIOOptions options)
 {
     ServerUri = uri ?? throw new ArgumentNullException("uri");
     Options   = options ?? throw new ArgumentNullException("options");
     Initialize();
 }