Exemple #1
0
        //Aca iniciamos todo lo qe corre por atras en el cliente. Ejemplo: Remoting
        public void StartProcess()
        {
            try
            {
                _remotingService = RemotingProtocol.GetRemotingProxy(ClientData.Instance.RemotingServerIP,
                                                                     ClientData.Instance.RemotingServerPort);

                CurrentStatus = "Exito: Servicio de remoting conectado";
            }
            catch (Exception ex)
            {
                CurrentStatus = "Error: Servicio remoting";
            }
        }
        public void Start()
        {
            //Start every process
            Console.WriteLine("Starting server.");

            //Inicializo el remoting
            _remotingService = RemotingProtocol.GetRemotingProxy(ServerData.Instance.RemotingServerIP,
                                                                 ServerData.Instance.RemotingServerPort);

            ListenProcess = new TCPClientListener(_remotingService);


            ClientListenerArray = new TcpListener[ServerData.Instance.MaxConnections];



            IPEndPoint endpoint    = new IPEndPoint(IPAddress.Any, ServerData.Instance.TCPPortForClients);
            var        tcpListener = new TcpListener(endpoint);

            for (int i = 0; i < ServerData.Instance.MaxConnections; i++)
            {
                ClientListenerArray[i] = tcpListener;
                ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), i);
            }


            SyncFilesProccess = new SyncFiles();
            IPEndPoint endpointForSync       = new IPEndPoint(IPAddress.Any, ServerData.Instance.TCPPortForServers);
            var        tcpListenerForServers = new TcpListener(endpointForSync);


            ThreadStart serverSyncRecieveThread = delegate { SyncFilesProccess.SyncRecieve(tcpListenerForServers); };

            syncServerThread = new Thread(serverSyncRecieveThread);
            syncServerThread.IsBackground = true;
            syncServerThread.Start();
        }