private string getAuthorizationHeader()
 {
     if (credentialsProvider.GetDeviceId() == SignalServiceAddress.DEFAULT_DEVICE_ID)
     {
         return("Basic " + Base64.encodeBytes(Encoding.UTF8.GetBytes((credentialsProvider.GetUser() + ":" + credentialsProvider.GetPassword()))));
     }
     else
     {
         return("Basic " + Base64.encodeBytes(Encoding.UTF8.GetBytes((credentialsProvider.GetUser() + "." + credentialsProvider.GetDeviceId() + ":" + credentialsProvider.GetPassword()))));
     }
 }
예제 #2
0
 public SignalWebSocketConnection(CancellationToken token, string httpUri, CredentialsProvider credentialsProvider, string userAgent)
 {
     Token = token;
     CredentialsProvider = credentialsProvider;
     UserAgent           = userAgent;
     if (credentialsProvider.GetDeviceId() == SignalServiceAddress.DEFAULT_DEVICE_ID)
     {
         WsUri = httpUri.Replace("https://", "wss://")
                 .Replace("http://", "ws://") + $"/v1/websocket/?login={credentialsProvider.GetUser()}&password={credentialsProvider.GetPassword()}";
     }
     else
     {
         WsUri = httpUri.Replace("https://", "wss://")
                 .Replace("http://", "ws://") + $"/v1/websocket/?login={credentialsProvider.GetUser()}.{credentialsProvider.GetDeviceId()}&password={credentialsProvider.GetPassword()}";
     }
     UserAgent = userAgent;
     WebSocket = new WebSocketWrapper(WsUri, token);
     WebSocket.OnConnect(Connection_OnOpened);
     WebSocket.OnMessage(Connection_OnMessage);
 }