private static async Task <IWampChannel> ConnectAsync(AppArguments appArguments) { var factory = new DefaultWampChannelFactory(); IWampClientAuthenticator clientAuthenticator = GetClientAuthenticator(appArguments.AuthMethod, appArguments.AuthId); var channel = clientAuthenticator == null ? factory.CreateJsonChannel(GetUri(appArguments), appArguments.Realm) : factory.CreateJsonChannel(GetUri(appArguments), appArguments.Realm, clientAuthenticator); while (!channel.RealmProxy.Monitor.IsConnected) { try { Console.WriteLine($"Trying to connect to the server {appArguments.Uri}..."); channel.Open().Wait(); } catch (Exception e) { Console.WriteLine($"Failed to connect: {e.Message}"); Console.WriteLine("Retrying in 5 sec..."); await Task.Delay(TimeSpan.FromSeconds(5)); } } return(channel); }
public WampSessionClient(IWampRealmProxy realm, IWampFormatter <TMessage> formatter, IWampClientAuthenticator authenticator) { mRealm = realm; mFormatter = formatter; mServerProxy = realm.Proxy; mAuthenticator = authenticator ?? new DefaultWampClientAuthenticator(); }
public IWampChannel CreateChannel<TMessage>(string realm, IControlledWampConnection<TMessage> connection, IWampBinding<TMessage> binding, IWampClientAuthenticator authenticator) { WampChannelBuilder<TMessage> builder = GetChannelBuilder(binding); WampChannel<TMessage> channel = builder.CreateChannel(realm, connection, authenticator); return channel; }
public WampRealmProxyFactory(WampChannelBuilder <TMessage> parent, string realmName, IWampConnection <TMessage> connection, IWampClientAuthenticator authenticator) : this(parent, realmName, connection) { mAuthenticator = authenticator; }
public IWampChannel CreateChannel<TMessage>(string realm, Func<IControlledWampConnection<TMessage>> connectionFactory, IWampBinding<TMessage> binding, IWampClientAuthenticator authenticator) { return this.CreateChannel(realm, new ReviveClientConnection<TMessage>(connectionFactory), binding, authenticator); }
/// <summary> /// Indicates that the user wants to use a given <see cref="IWampClientAuthenticator"/>. /// </summary> /// <param name="authenticator">The given <see cref="IWampClientAuthenticator"/>.</param> public static ChannelFactorySyntax.IAuthenticationSyntax Authenticator(this ChannelFactorySyntax.ISerializationSyntax serializationSyntax, IWampClientAuthenticator authenticator) { ChannelState state = serializationSyntax.State; state.Authenticator = authenticator; return(state); }
/// <summary> /// Creates a <see cref="IWampChannel"/> that connects to a given realm, /// using the given address and the given text binding /// </summary> /// <param name="address">The given address.</param> /// <param name="realm">The given realm to connect to.</param> /// <param name="binding">The given text binding.</param> /// <param name="authenticator">The authenticator object to handle CHALLENGE request.</param> /// <returns></returns> public IWampChannel CreateChannel <TMessage>(string address, string realm, IWampTextBinding <TMessage> binding, IWampClientAuthenticator authenticator) { var connection = new MessageWebSocketTextConnection <TMessage>(address, binding); return(this.CreateChannel(realm, connection, binding, authenticator)); }
/// <summary> /// Creates a <see cref="IWampChannel"/> that connects to a given realm, /// using the given address and the given binary binding /// </summary> /// <param name="address">The given address.</param> /// <param name="realm">The given realm to connect to.</param> /// <param name="binding">The given binary binding.</param> /// <param name="authenticator">The authenticator object to handle CHALLENGE request.</param> /// <returns></returns> public IWampChannel CreateChannel <TMessage>(string address, string realm, IWampBinaryBinding <TMessage> binding, IWampClientAuthenticator authenticator) { Func <IControlledWampConnection <TMessage> > connectionFactory = () => new WebSocket4NetBinaryConnection <TMessage>(address, binding); return(this.CreateChannel(realm, connectionFactory, binding, authenticator)); }
/// <summary> /// Creates a <see cref="IWampChannel"/> that connects to a given realm, /// using the given address and the given text binding /// </summary> /// <param name="address">The given address.</param> /// <param name="realm">The given realm to connect to.</param> /// <param name="binding">The given text binding.</param> /// <param name="authenticator">The authenticator object to handle CHALLENGE request.</param> /// <returns></returns> public IWampChannel CreateChannel <TMessage>(string address, string realm, IWampTextBinding <TMessage> binding, IWampClientAuthenticator authenticator) { Func <IControlledWampConnection <TMessage> > connectionFactory = () => new ControlledTextWebSocketConnection <TMessage>(new Uri(address), binding, null); return(this.CreateChannel(realm, connectionFactory, binding, authenticator)); }
public WampChannel <TMessage> CreateChannel(string realm, IControlledWampConnection <TMessage> connection, IWampClientAuthenticator authenticator) { var wampRealmProxyFactory = new WampRealmProxyFactory(this, realm, connection, authenticator); WampClient <TMessage> client = new WampClient <TMessage>(wampRealmProxyFactory); return(new WampChannel <TMessage>(connection, client)); }
public WampRealmProxy(string name, IWampServerProxy proxy, IWampBinding <TMessage> binding, IWampClientAuthenticator authenticator) { mName = name; mProxy = proxy; IWampFormatter <TMessage> formatter = binding.Formatter; mMonitor = new WampSessionClient <TMessage>(this, formatter, authenticator); mRpcCatalog = new WampRpcOperationCatalogProxy <TMessage>(proxy, formatter, mMonitor); mTopicContainer = new WampTopicContainerProxy <TMessage>(proxy, formatter, mMonitor); mServices = new WampRealmProxyServiceProvider(this); mAuthenticator = authenticator; }
public PcaWampClient(Uri address, string realm, IWampClientAuthenticator authenticator, TypeMapper typeMapper) { var serializer = new Newtonsoft.Json.JsonSerializer(); if (typeMapper != null) { serializer.Converters.Add(new DerivedEntityJsonConverter(typeMapper)); } var builder = new WampChannelFactory().ConnectToRealm(realm) .WebSocketTransport(address) .JsonSerialization(serializer); this.channel = authenticator != null? builder.Authenticator(authenticator).Build() : builder.Build(); }
private static async Task <IWampChannel> ConnectAsync(AppArguments appArguments) { var factory = new DefaultWampChannelFactory(); IWampClientAuthenticator clientAuthenticator = GetClientAuthenticator(appArguments.AuthMethod, appArguments.AuthId); var channel = clientAuthenticator == null ? factory.CreateJsonChannel(GetUri(appArguments), appArguments.Realm) : factory.CreateJsonChannel(GetUri(appArguments), appArguments.Realm, clientAuthenticator); channel.RealmProxy.Monitor.ConnectionEstablished += (sender, args) => { Console.WriteLine("connected session with ID " + args.SessionId); dynamic details = args.WelcomeDetails.OriginalValue.Deserialize <dynamic>(); Console.WriteLine("authenticated using method '{0}' and provider '{1}'", details.authmethod, details.authprovider); Console.WriteLine("authenticated with authid '{0}' and authrole '{1}'", details.authid, details.authrole); }; while (!channel.RealmProxy.Monitor.IsConnected) { try { Console.WriteLine($"Trying to connect to the server {appArguments.Uri}..."); channel.Open().Wait(); } catch (Exception e) { Console.WriteLine($"Failed to connect: {e.Message}"); Console.WriteLine("Retrying in 5 sec..."); await Task.Delay(TimeSpan.FromSeconds(5)); } } return(channel); }
public async Task <bool> Connect() { if (this._channel == null) { if (string.IsNullOrEmpty(this._parameters.Login)) { this._channel = this._factory.CreateJsonChannel(this.GetURI(), this._parameters.ServerRealm); } else { if (string.IsNullOrEmpty(this._parameters.Salt)) { this._authenticator = new WampCraClientAuthenticator ( authenticationId: this._parameters.Login, secret: this._parameters.Password ); } else { this._authenticator = new WampCraClientAuthenticator ( authenticationId: this._parameters.Login, secret: this._parameters.Password, salt: this._parameters.Salt, iterations: this._parameters.Iterations, keyLen: this._parameters.KeyLen ); } this._channel = this._factory.CreateJsonChannel(this.GetURI(), this._parameters.ServerRealm, this._authenticator); } await this._channel.Open().ConfigureAwait(false); } return(this._channel.RealmProxy.Monitor.IsConnected); }
/// <summary> /// Creates a <see cref="IWampChannel"/> that connects to a given realm, /// using the given address and json binding /// </summary> /// <param name="address">The given address.</param> /// <param name="realm">The given realm to connect to.</param> /// <param name="authenticator">The authenticator object to handle CHALLENGE request.</param> /// <returns></returns> public IWampChannel CreateJsonChannel(string address, string realm, IWampClientAuthenticator authenticator) { return(this.CreateChannel(address, realm, mJsonBinding, authenticator)); }