private static void KeepAliveTimerProc(object state)
        {
            TwoWayRemotingServerBase server = (TwoWayRemotingServerBase)state;

            // Loop through the connected clients and ping them
            lock (server.connectedClients)
            {
                foreach (string key in server.connectedClients.Keys)
                {
                    server.InternalCallClientMethodAsync(server.connectedClients[key].ClientObject, server.connectedClients[key].RemoteUri, "Ping", true);
                }
            }
        }
        private static void InvokeClientMethod(TwoWayRemotingServerBase server, ITwoWayRemotingClient clientObject, string clientUri, string methodName, bool disconnectOnException, params object[] methodArgs)
        {
            // Create a list of our parameter types
            List <Type> paramTypes = new List <Type>(methodArgs.Length);

            foreach (object param in methodArgs)
            {
                paramTypes.Add(param.GetType());
            }

            System.Reflection.MethodInfo method = clientObject.GetType().GetMethod(methodName, paramTypes.ToArray());

            try
            {
                System.Net.IPAddress address = (System.Net.IPAddress)System.Runtime.Remoting.Messaging.CallContext.GetData("ClientIP");
                System.Diagnostics.Trace.WriteLine("****** Yo: " + server.GetClientID(clientObject));
                method.Invoke(clientObject, methodArgs);
                System.Diagnostics.Trace.WriteLine("*** Done");
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("*** Remoting Error: " + server.GetClientID(clientObject) + "\r\n\r\n" + e.ToString());
                if (e.InnerException != null)
                {
                    if (disconnectOnException)
                    {
                        server.DisconnectClient(clientObject, null, false);
                    }
                    else
                    {
                        server.OnClientMethodError(clientObject, e.InnerException);
                    }
                }
                else
                {
                    if (disconnectOnException)
                    {
                        server.DisconnectClient(clientObject, null, false);
                    }
                    else
                    {
                        server.OnClientMethodError(clientObject, e);
                    }
                }
            }
        }
        private static void InvokeClientMethod(TwoWayRemotingServerBase server, ITwoWayRemotingClient clientObject, string clientUri, string methodName, bool disconnectOnException, params object[] methodArgs)
        {
            // Create a list of our parameter types
            List<Type> paramTypes = new List<Type>(methodArgs.Length);
            foreach (object param in methodArgs)
            {
                paramTypes.Add(param.GetType());
            }

            System.Reflection.MethodInfo method = clientObject.GetType().GetMethod(methodName, paramTypes.ToArray());

            try
            {
                System.Net.IPAddress address = (System.Net.IPAddress)System.Runtime.Remoting.Messaging.CallContext.GetData("ClientIP");
                System.Diagnostics.Trace.WriteLine("****** Yo: " + server.GetClientID(clientObject));
                method.Invoke(clientObject, methodArgs);
                System.Diagnostics.Trace.WriteLine("*** Done");
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("*** Remoting Error: " + server.GetClientID(clientObject) + "\r\n\r\n" + e.ToString());
                if (e.InnerException != null)
                {
                    if (disconnectOnException)
                        server.DisconnectClient(clientObject, null, false);
                    else
                        server.OnClientMethodError(clientObject, e.InnerException);
                }
                else
                {
                    if (disconnectOnException)
                        server.DisconnectClient(clientObject, null, false);
                    else
                        server.OnClientMethodError(clientObject, e);
                }
            }
        }