Ejemplo n.º 1
0
        private void RegisterNetworkListener(XDTransportMode mode)
        {
            if (disposed)
            {
                return;
            }

            if (!IsAlive)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                propagateListener.RegisterChannel(
                    NetworkRelayBroadcaster.GetNetworkListenerName(mode));
                propagateListener.MessageReceived += OnNetworkMessageReceived;
            }).ContinueWith(t =>
            {
                // ReSharper disable once UnusedVariable
                var e = t.Exception;
                if (disposed)
                {
                    return;
                }

                Thread.Sleep(NetworkReTryTimeoutMilliSeconds);
                RegisterNetworkListener(mode);
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
        private void RegisterNetworkListener(XDTransportMode mode)
        {
            if (disposed)
            {
                return;
            }

            if (!IsAlive)
            {
                return;
            }

            // listen on the network channel for this mode
            Task.Factory.StartNew(() =>
            {
                propagateListener.RegisterChannel(
                    NetworkRelayBroadcaster.GetNetworkListenerName(mode));
                propagateListener.MessageReceived += OnNetworkMessageReceived;
            }).ContinueWith(t =>
            {
                var e = t.Exception;
                if (!disposed)
                {
                    Thread.Sleep(networkReTryTimeoutMilliSeconds);
                    // retry attach listener
                    RegisterNetworkListener(mode);
                }
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
Ejemplo n.º 3
0
        public IXDBroadcaster GetBroadcasterForMode(XDTransportMode transportMode, bool propagateNetwork)
        {
            var broadcaster = GetBroadcasterForModeInternal(transportMode);
            if (!propagateNetwork || transportMode == XDTransportMode.RemoteNetwork)
            {
                return broadcaster;
            }

            var remoteBroadcaster = CreateNetworkBroadcaster();
            if (!remoteBroadcaster.IsAlive)
            {
                throw new ConfigurationErrorsException(
                    "The RemoteNetwork Broadcaster is not configured. Check the configuration settings.");
            }

            var relayBroadcaster = new NetworkRelayBroadcaster(
                serializer,
                transportMode,
                remoteBroadcaster);

            return client.Broadcasters.GetMulticastBroadcaster(broadcaster, relayBroadcaster);
        }
Ejemplo n.º 4
0
 public IXDBroadcaster GetBroadcasterForMode(XDTransportMode transportMode, bool propagateNetwork)
 {
     var broadcaster = Container.Resolve<IXDBroadcaster>(Convert.ToString(transportMode));
     if (broadcaster == null)
     {
         throw new NotSupportedException(
             string.Format(
                 "No concrete IXDBroadcast for mode {0} could be loaded. Install the {0} assembly in the program directory.",
                 transportMode));
     }
     if (propagateNetwork && transportMode != XDTransportMode.RemoteNetwork)
     {
         var remoteBroadcaster = messagingClient.Broadcasters.GetBroadcasterForMode(XDTransportMode.RemoteNetwork);              
         if (!remoteBroadcaster.IsAlive)
         {
             throw new ConfigurationErrorsException("The RemoteNetwork Broadcaster is not configured. Check the configuration settings.");
         }
         var relayBroadcaster = new NetworkRelayBroadcaster(Container.Resolve<ISerializer>(), transportMode,
                                                            remoteBroadcaster);
         broadcaster = messagingClient.Broadcasters.GetMulticastBroadcaster(broadcaster, relayBroadcaster);
     }
     return broadcaster;
 }