Esempio n. 1
0
        public Client(string username, string port, string cDirUrl)
        {
            //With 0 as port the remoting services will chose an available port automatically
            IDictionary prop = new Hashtable();

            prop["name"]   = "ClientChannel." + username;
            prop["port"]   = port;
            mClientChannel = new TcpChannel(prop, null, null);
            ChannelServices.RegisterChannel(mClientChannel, true);

            string clientName = username;

            RemotingServices.Marshal(this, clientName, typeof(IClient));

            String[] urls = ChannelServices.GetUrlsForObject(this);

            this.URL = urls[0];

            System.Console.WriteLine("Client instantiated with name " + clientName + " and URL " + urls[0]);

            try
            {
                CDIR_URL    = cDirUrl;
                mCentralDir = (ICentralDir)Activator.GetObject(typeof(IClient), CDIR_URL);

                if (mCentralDir == null)
                {
                    System.Console.WriteLine("Cannot get central directory object for " + CDIR_URL);
                    throw new RemoteException("Cannot get central directory object for " + CDIR_URL);
                }
            }
            catch (SocketException)
            {
                throw new RemoteException("Could not connect to central directory: central directory url " + CDIR_URL);
            }

            System.Console.WriteLine("Central Directory with URL " + CDIR_URL);

            isSleep          = false;
            mRegisterManager = new RegisterManager();
            mNodeRouter      = new NodeRouter();
            mClientThread    = new ClientThread();

            System.Console.WriteLine("Register Manager created");
            System.Console.WriteLine("Node Router created");
            System.Console.WriteLine("Client Thread created");

            mActiveTransaction = new TransactionContext();
            System.Console.Write("Transaction Context created with id: " + mActiveTransaction.TxID + " valuesOfKey: ");
            mActiveTransaction.printKeyValues();
            System.Console.WriteLine("state: " + mActiveTransaction.TransactionState);
        }
Esempio n. 2
0
 public Client(String sConfigPath, ISimpleConnectReceiver receiver, String sClientName)
 {
     clientThread = new ClientThread(sConfigPath, receiver, sClientName);
 }
Esempio n. 3
0
        public Client(string username, string port, string cDirUrl)
        {
            //With 0 as port the remoting services will chose an available port automatically
            IDictionary prop = new Hashtable();
            prop["name"] = "ClientChannel." + username;
            prop["port"] = port;
            mClientChannel = new TcpChannel(prop, null, null);
            ChannelServices.RegisterChannel(mClientChannel, true);

            string clientName = username;
            RemotingServices.Marshal(this, clientName, typeof(IClient));

            String[] urls = ChannelServices.GetUrlsForObject(this);

            this.URL = urls[0];

            System.Console.WriteLine("Client instantiated with name " + clientName + " and URL " + urls[0]);

            try
            {
                CDIR_URL = cDirUrl;
                mCentralDir = (ICentralDir)Activator.GetObject(typeof(IClient), CDIR_URL);

                if (mCentralDir == null)
                {
                    System.Console.WriteLine("Cannot get central directory object for " + CDIR_URL);
                    throw new RemoteException("Cannot get central directory object for " + CDIR_URL);
                }
            }
            catch (SocketException)
            {
                throw new RemoteException("Could not connect to central directory: central directory url " + CDIR_URL);
            }

            System.Console.WriteLine("Central Directory with URL " + CDIR_URL);

            isSleep = false;
            mRegisterManager = new RegisterManager();
            mNodeRouter = new NodeRouter();
            mClientThread = new ClientThread();

            System.Console.WriteLine("Register Manager created");
            System.Console.WriteLine("Node Router created");
            System.Console.WriteLine("Client Thread created");

            mActiveTransaction = new TransactionContext();
            System.Console.Write("Transaction Context created with id: " + mActiveTransaction.TxID + " valuesOfKey: ");
            mActiveTransaction.printKeyValues();
            System.Console.WriteLine("state: " + mActiveTransaction.TransactionState);
        }