public ProvisioningSocket(string httpUri, ISignalWebSocketFactory webSocketFactory, CancellationToken token) { WsUri = httpUri.Replace("https://", "wss://") .Replace("http://", "ws://") + "/v1/websocket/provisioning/"; SignalWebSocket = webSocketFactory.CreateSignalWebSocket(token, new Uri(WsUri)); SignalWebSocket.MessageReceived += SignalWebSocket_MessageReceived; }
internal SignalServiceMessagePipe(CancellationToken token, SignalWebSocketConnection websocket, ICredentialsProvider credentialsProvider, ISignalWebSocketFactory webSocketFactory) { Logger.LogTrace("SignalServiceMessagePipe()"); Token = token; Websocket = websocket; CredentialsProvider = credentialsProvider; SignalWebSocketFactory = webSocketFactory; }
/// <summary> /// Request a UUID from the server for linking as a new device. /// Called by the new device. /// </summary> /// <param name="webSocketFactory">A factory which creates websocket connection objects</param> /// <param name="token">A CancellationToken for the PrivisioningSocket's websocket connection</param> /// <returns></returns> public async Task <string> GetNewDeviceUuidAsync(ISignalWebSocketFactory webSocketFactory, CancellationToken?token = null) { if (token == null) { token = CancellationToken.None; } provisioningSocket = new ProvisioningSocket(configuration.SignalServiceUrls[0].Url, webSocketFactory, token); return((await provisioningSocket.GetProvisioningUuidAsync(token)).Uuid); }
public ProvisioningSocket(string httpUri, ISignalWebSocketFactory webSocketFactory, CancellationToken?token = null) { if (token == null) { token = CancellationToken.None; } wsUri = httpUri.Replace("https://", "wss://") .Replace("http://", "ws://") + "/v1/websocket/provisioning/"; signalWebSocket = webSocketFactory.CreateSignalWebSocket(new Uri(wsUri), token); signalWebSocket.MessageReceived += SignalWebSocket_MessageReceived; }
/// <summary> /// Creates a pipe for receiving SignalService messages. /// /// Callers must call <see cref="SignalServiceMessagePipe.Shutdown()"/> when finished with the pipe. /// </summary> /// <returns>A SignalServiceMessagePipe for receiving Signal Service messages.</returns> public async Task <SignalServiceMessagePipe> CreateMessagePipeAsync(ISignalWebSocketFactory webSocketFactory, CancellationToken?token = null) { if (token == null) { token = CancellationToken.None; } SignalWebSocketConnection webSocket = new SignalWebSocketConnection(urls.SignalServiceUrls[0].Url, credentialsProvider, userAgent, webSocketFactory, token); var messagePipe = new SignalServiceMessagePipe(webSocket, credentialsProvider, webSocketFactory, token); await messagePipe.Connect(); return(messagePipe); }
internal SignalServiceMessagePipe(SignalWebSocketConnection websocket, ICredentialsProvider?credentialsProvider, ISignalWebSocketFactory webSocketFactory, CancellationToken?token = null) { if (token == null) { token = CancellationToken.None; } logger.LogTrace("SignalServiceMessagePipe()"); this.token = token.Value; this.websocket = websocket; this.credentialsProvider = credentialsProvider; signalWebSocketFactory = webSocketFactory; }
/// <summary> /// Creates an unidentified message pipe. /// /// Callers must call <see cref="SignalServiceMessagePipe.Shutdown()"/> when finished with the pipe. /// </summary> /// <returns>A SignalServiceMessagePipe for receiving Signal Service messages.</returns> public async Task <SignalServiceMessagePipe> CreateUnidentifiedMessagePipe(CancellationToken token, ISignalWebSocketFactory webSocketFactory) { SignalWebSocketConnection webSocket = new SignalWebSocketConnection(token, Urls.SignalServiceUrls[0].Url, null, UserAgent, webSocketFactory); var messagePipe = new SignalServiceMessagePipe(token, webSocket, CredentialsProvider, webSocketFactory); await messagePipe.Connect(); return(messagePipe); }
/// <summary> /// Construct a SignalServiceAccountManager for linking as a slave device /// </summary> /// <param name="configuration">The URL configuration for the Signal Service</param> /// <param name="userAgent">A string which identifies the client software</param> /// <param name="webSocketFactory">A factory which creates websocket connection objects</param> public SignalServiceAccountManager(SignalServiceConfiguration configuration, string userAgent, ISignalWebSocketFactory webSocketFactory) { Configuration = configuration; UserAgent = userAgent; PushServiceSocket = new PushServiceSocket(configuration, new StaticCredentialsProvider(null, null, null, (int)SignalServiceAddress.DEFAULT_DEVICE_ID), userAgent); }
/// <summary> /// Request a UUID from the server for linking as a new device. /// Called by the new device. /// </summary> /// <param name="token">A CancellationToken for the PrivisioningSocket's websocket connection</param> /// /// <param name="webSocketFactory">A factory which creates websocket connection objects</param> /// <returns></returns> public async Task <string> GetNewDeviceUuid(CancellationToken token, ISignalWebSocketFactory webSocketFactory) { ProvisioningSocket = new ProvisioningSocket(Configuration.SignalServiceUrls[0].Url, webSocketFactory, token); return((await ProvisioningSocket.GetProvisioningUuid(token)).Uuid); }
/// <summary> /// Construct a SignalServiceAccountManager for linking as a slave device /// </summary> /// <param name="configuration">The URL configuration for the Signal Service</param> /// <param name="userAgent">A string which identifies the client software</param> /// <param name="webSocketFactory">A factory which creates websocket connection objects</param> public SignalServiceAccountManager(SignalServiceConfiguration configuration, string userAgent, HttpClient httpClient, ISignalWebSocketFactory webSocketFactory) { this.httpClient = httpClient; this.configuration = configuration; this.userAgent = userAgent; credentials = new StaticCredentialsProvider(null, null, null, (int)SignalServiceAddress.DEFAULT_DEVICE_ID); pushServiceSocket = new PushServiceSocket(configuration, credentials, userAgent, httpClient); }