1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace EZXR.Glass.Network.SocketIOClient
- {
- public class UrlConverter
- {
- public Uri HttpToWs(Uri httpUri, string eio, Dictionary<string, string> parameters)
- {
- 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("/socket.io/?EIO=")
- .Append(eio)
- .Append("&transport=websocket");
- if (parameters != null)
- {
- foreach (var item in parameters)
- {
- builder
- .Append("&")
- .Append(item.Key)
- .Append("=")
- .Append(item.Value);
- }
- }
- return new Uri(builder.ToString());
- }
- }
- }
|