Beispiel #1
0
        /// <summary>
        /// Start the client-repeater instance.
        /// </summary>
        /// <remarks>
        /// Note: the behaviour of this method was changed with GT 3.0
        /// such that a new thread is no longer launched for handling incoming
        /// messages.  Callers desiring this behaviour should call <see cref="StartSeparateListeningThread"/>
        /// instead.
        /// </remarks>
        public void Start()
        {
            if (server == null)
            {
                server = config.BuildServer();
                server.MessageReceived += s_MessageReceived;
                server.ClientsJoined += s_ClientsJoined;
                server.ClientsRemoved += s_ClientsRemoved;
                server.ErrorEvent += s_ErrorEvent;

                // Some transports are unreliable, meaning that we cannot tell whether
                // a remote has stopped communicating because they have shutdown ungracefully
                // (e.g., crashed), because the network is down, or because they haven't
                // sent a reply.  The PingBasedDisconnector uses the ping response time
                // to automatically drop inactive connections.
                if (InactiveTransportTimeout.TotalSeconds > 0)
                {
                    pbd = new PingBasedDisconnector(server, InactiveTransportTimeout);
                    pbd.ErrorEvent += s_ErrorEvent;
                }
            }
            if(!server.Active)
            {
                server.Start();
                if (pbd != null) { pbd.Start(); }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Install a disconnector on the provided communicator.
 /// </summary>
 /// <param name="c"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public static PingBasedDisconnector Install(Communicator c, TimeSpan timeout)
 {
     PingBasedDisconnector instance = new PingBasedDisconnector(c, timeout);
     instance.Start();
     return instance;
 }