public AblyClientService(IConfiguration _configuration) { var realtime = new AblyRealtime(_configuration.GetValue <string>("ably")); realtime.Connect(); Client = realtime; }
public async Task <bool> InitializeAsync() { var task = new TaskCompletionSource <bool>(); _client = new AblyRealtime(new ClientOptions() { Key = AblyApiKey, EchoMessages = false // prevent messages the client sends echoing back }); _client.Connection.On(args => { if (args.Current == IO.Ably.Realtime.ConnectionState.Connected) { // channels don't get automatically reattached // if the connection drop, so do that manually foreach (var channel in _client.Channels) { channel.Attach(); } _channel = _client.Channels.Get("general"); _channel.Subscribe(MessageEvent, (IO.Ably.Message msg) => { Console.WriteLine(msg.ClientId); }); task.SetResult(true); } if (args.Current == IO.Ably.Realtime.ConnectionState.Disconnected) { _client.Connect(); } }); return(await task.Task.ConfigureAwait(false)); }
private void ConnectClickHandler() { _clientOptions.ClientId = _clientId.text; if (_isConnected) { _ably.Close(); } else { _ably.Connect(); } }
public void AutoConnectOff() { var realtime = new AblyRealtime(new ClientOptions(PlaceholderKey) { AutoConnect = false }); realtime.Connect(); realtime.Connection.On(args => { var currentState = args.Current; // Current state the connection transitioned to var previousState = args.Previous; // Previous state var error = args.Reason; // If the connection error-ed the 'Reason' object will be populated. }); }
public void Connect() { _ably.Connect(); }