/// <summary> /// Connect to the XMPP server. /// This establishes the connection to the server, including TLS, authentication, resource binding and /// compression. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> /// <exception cref="AuthenticationException">Thrown when the authentication fails.</exception> /// <exception cref="BindException">Thrown when resource binding fails.</exception> /// <exception cref="StreamErrorException">Throws a StreamErrorException when the server returns a stream error.</exception> /// <exception cref="CompressionException">Throws a CompressionException when establishing stream compression fails.</exception> /// <exception cref="RegisterException">Throws aRegisterException when new account registration fails.</exception> public async Task <IChannel> ConnectAsync(CancellationToken cancellationToken) { var iChannel = await Bootstrap.ConnectAsync(XmppDomain, Port); SessionState = SessionState.Connected; if (HostnameResolver.Implements <IDirectTls>() && HostnameResolver.Cast <IDirectTls>().DirectTls == true) { await DoSslAsync(cancellationToken); } var feat = await SendStreamHeaderAsync(cancellationToken); var streamFeatures = await HandleStreamFeaturesAsync(feat, cancellationToken); var open = new Open() { From = Pipeline.Get <StreamPropsCaptureHandler>().From, Id = Pipeline.Get <StreamPropsCaptureHandler>().Id, Version = Pipeline.Get <StreamPropsCaptureHandler>().Version, }; await WebSocket.SendText(open.ToString(false)); // lets add the forwarding handler now this.Pipeline.AddBefore <CatchAllXmppStanzaHandler>(new ForwardHandler(this.WebSocket)); await WebSocket.SendText(streamFeatures.ToString(false)); return(iChannel); }
/// <summary> /// Loads App resources. Called on App_Startup /// </summary> /// <returns></returns> public async Task Load() { Log = new Logger(); CompanyViewModel = new CompanyViewModel(DialogCoordinator.Instance); ConnectionViewModel = new ConnectionViewModel(DialogCoordinator.Instance); Connection = Connection.Load(); ConnectionViewModel.Connection = Connection; // Wait for MainWindow while (App.Current.MainWindow == null) { await Task.Delay(1000); } // Get Hostname list for configuration Task.Run(() => ConnectionViewModel.Hostnames = HostnameResolver.GetHostnameList()); // Potential valid connection if (!Connection.IsEmpty) { // Connect to database if (await ConnectionViewModel.Connect(false)) { return; } } // Move to ConnectionView tab page (App.Current.MainWindow as MainWindow).SelectedIndex++; }
/// <summary> /// Connect to the XMPP server. /// This establishes the connection to the server, including TLS, authentication, resource binding and /// compression. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> /// <exception cref="AuthenticationException">Thrown when the authentication fails.</exception> /// <exception cref="BindException">Thrown when resource binding fails.</exception> /// <exception cref="StreamErrorException">Throws a StreamErrorException when the server returns a stream error.</exception> /// <exception cref="CompressionException">Throws a CompressionException when establishing stream compression fails.</exception> /// <exception cref="RegisterException">Throws aRegisterException when new account registration fails.</exception> public override async Task <IChannel> ConnectAsync(CancellationToken cancellationToken) { var iChannel = await Bootstrap.ConnectAsync(XmppDomain, Port); XmppSessionState.Value = SessionState.Connected; if (HostnameResolver.Implements <IDirectTls>() && HostnameResolver.Cast <IDirectTls>().DirectTls == true) { await DoSslAsync(cancellationToken); } var feat = await SendStreamHeaderAsync(cancellationToken); await HandleStreamFeaturesAsync(feat, cancellationToken); return(iChannel); }
/// <param name="hostnameResolver"> </param> /// <param name="config"> </param> public InitialDiscoveryMembersResolver(HostnameResolver hostnameResolver, Config config) { this._hostnameResolver = hostnameResolver; this._advertisedSocketAddresses = (System.Collections.IList)config.Get(CausalClusteringSettings.initial_discovery_members); }