/// <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 SignalServiceMessageSender /// </summary> /// <param name="token">A CancellationToken to cancel the sender's operations</param> /// <param name="urls">The URL of the Signal Service.</param> /// <param name="user">The Signal Service username (eg phone number).</param> /// <param name="password">The Signal Service user password</param> /// <param name="deviceId">Tbe Signal Service device id</param> /// <param name="store">The SignalProtocolStore.</param> /// <param name="pipe">An optional SignalServiceMessagePipe</param> /// <param name="eventListener">An optional event listener, which fires whenever sessions are /// setup or torn down for a recipient.</param> /// <param name="userAgent"></param> public SignalServiceMessageSender(CancellationToken token, SignalServiceConfiguration urls, string user, string password, int deviceId, SignalProtocolStore store, SignalServiceMessagePipe pipe, IEventListener eventListener, string userAgent) { Token = token; CredentialsProvider = new StaticCredentialsProvider(user, password, null, deviceId); this.socket = new PushServiceSocket(urls, CredentialsProvider, userAgent); this.store = store; this.localAddress = new SignalServiceAddress(user); this.pipe = pipe; this.eventListener = eventListener; }
/// <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> CreateUnidentifiedMessagePipeAsync(ISignalWebSocketFactory webSocketFactory, CancellationToken?token = null) { if (token == null) { token = CancellationToken.None; } SignalWebSocketConnection webSocket = new SignalWebSocketConnection(urls.SignalServiceUrls[0].Url, null, userAgent, webSocketFactory, token); var messagePipe = new SignalServiceMessagePipe(webSocket, credentialsProvider, webSocketFactory, token); await messagePipe.Connect(); return(messagePipe); }