Exemplo n.º 1
0
 public override void Connect()
 {
     if (wSocket != null)
     {
         HTTPManager.Logger.Warning("WebSocketTransport", "Start - WebSocket already created!");
     }
     else
     {
         if (base.State != TransportStates.Reconnecting)
         {
             base.State = TransportStates.Connecting;
         }
         RequestTypes type = (base.State != TransportStates.Reconnecting) ? RequestTypes.Connect : RequestTypes.Reconnect;
         Uri          uri  = base.Connection.BuildUri(type, this);
         wSocket = new VRC.Core.BestHTTP.WebSocket.WebSocket(uri);
         VRC.Core.BestHTTP.WebSocket.WebSocket webSocket = wSocket;
         webSocket.OnOpen = (OnWebSocketOpenDelegate)Delegate.Combine(webSocket.OnOpen, new OnWebSocketOpenDelegate(WSocket_OnOpen));
         VRC.Core.BestHTTP.WebSocket.WebSocket webSocket2 = wSocket;
         webSocket2.OnMessage = (OnWebSocketMessageDelegate)Delegate.Combine(webSocket2.OnMessage, new OnWebSocketMessageDelegate(WSocket_OnMessage));
         VRC.Core.BestHTTP.WebSocket.WebSocket webSocket3 = wSocket;
         webSocket3.OnClosed = (OnWebSocketClosedDelegate)Delegate.Combine(webSocket3.OnClosed, new OnWebSocketClosedDelegate(WSocket_OnClosed));
         VRC.Core.BestHTTP.WebSocket.WebSocket webSocket4 = wSocket;
         webSocket4.OnErrorDesc = (OnWebSocketErrorDescriptionDelegate)Delegate.Combine(webSocket4.OnErrorDesc, new OnWebSocketErrorDescriptionDelegate(WSocket_OnError));
         base.Connection.PrepareRequest(wSocket.InternalRequest, type);
         wSocket.Open();
     }
 }
Exemplo n.º 2
0
 public void Open()
 {
     if (State == TransportStates.Closed)
     {
         Uri uri = new Uri(string.Format("{0}?transport=websocket&sid={1}{2}", new UriBuilder((!HTTPProtocolFactory.IsSecureProtocol(Manager.Uri)) ? "ws" : "wss", Manager.Uri.Host, Manager.Uri.Port, Manager.Uri.PathAndQuery).Uri.ToString(), Manager.Handshake.Sid, Manager.Options.QueryParamsOnlyForHandshake ? string.Empty : Manager.Options.BuildQueryParams()));
         Implementation           = new VRC.Core.BestHTTP.WebSocket.WebSocket(uri);
         Implementation.OnOpen    = OnOpen;
         Implementation.OnMessage = OnMessage;
         Implementation.OnBinary  = OnBinary;
         Implementation.OnError   = OnError;
         Implementation.OnClosed  = OnClosed;
         Implementation.Open();
         State = TransportStates.Connecting;
     }
 }