public void SetupRemoteConnection()
        {
            var factory = new DefaultWampChannelFactory();

            _remoteChannel =
                factory.CreateJsonChannel(location, realm);

            Task connect()
            {
                return(Task.Run(async() =>
                {
                    try
                    {
                        _logger.Info(this, "Trying to connect");
                        _remoteChannel.Open().Wait(5000);
                        IWampRealmProxy realm = _remoteChannel.RealmProxy;
                        _logger.Info(this, "registering RPC");
                        await realm.Services.RegisterCallee(_service);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(this, ex.Message);
                        var exe = ex;
                        while (exe.InnerException != null)
                        {
                            exe = exe.InnerException;
                            _logger.Error(this, exe.Message);
                        }
                        await Task.Delay(5000);
                        throw;
                    }
                }));
            }

            _reconnector = new WampChannelReconnector(_remoteChannel, connect);

            _reconnector.Start();
        }
Esempio n. 2
0
 public void Start()
 {
     _reconnector.Start();
 }