public ServerThread(NodeRouter nodeRouter, KeyManager kManager) { mNodeRouter = nodeRouter; mKeyManager = kManager; mTimer = new Timer(); mTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); mTimer.Interval = interval; mTimer.Enabled = true; //Default is true (flag wich tells if we want the event to be raised more than one time) //mTimer.AutoReset = true; }
public Server(string username, string port, string cDirUrl) { IDictionary prop = new Hashtable(); prop["name"] = "ServerChannel." + username; prop["port"] = port; mServerChannel = new TcpChannel(prop, null, null); ChannelServices.RegisterChannel(mServerChannel, true); string serverName = username; RemotingServices.Marshal(this, serverName, typeof(IServer)); String[] urls = ChannelServices.GetUrlsForObject(this); this.URL = urls[0]; System.Console.WriteLine("Server instantiated with name " + serverName + " " + 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("Could not connect to central directory: central directory url " + CDIR_URL); Environment.Exit(0); } mKeyManager = new KeyManager(K); mTransactionManager = new TransactionManager(this, mKeyManager, K); mNodeRouter = new NodeRouter(mURL, mKeyManager, this); mServerThread = new ServerThread(mNodeRouter, mKeyManager); }