Beispiel #1
0
 public Server()
 {
     tupleSpaceLock = new ReaderWriterLockSlim();
     prepareRemoting(defaultPort, defaultname, defaultDelay, defaultDelay);
     fd         = new FailureDetector(url);
     tupleSpace = fd.updateTS();
 }
Beispiel #2
0
 public ServerObject(string[] args)
 {
     myUrl            = args[3];
     id               = args[1];
     msecperround     = Int32.Parse(args[4]);
     maxPlayersServer = Int32.Parse(args[5]);
     System.Console.WriteLine("Server Criado com argumentos");
     players         = new List <Player>();
     game            = new GameObject(msecperround);
     messages        = new List <string>();
     failureDetector = new FailureDetector();
     game.setFailureDetector(failureDetector);
 }
Beispiel #3
0
        public Server(string URL, string min_delay, string max_delay)
        {
            url = URL;
            string[] urlSplit = URL.Split(new Char[] { '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
            int      port, imin_delay, imax_delay;

            Int32.TryParse(urlSplit[2], out port);
            Int32.TryParse(min_delay, out imin_delay);
            Int32.TryParse(max_delay, out imax_delay);

            prepareRemoting(port, urlSplit[3], imin_delay, imax_delay);
            fd = new FailureDetector(this);
            Console.WriteLine("Hello! I'm a Server at port " + urlSplit[2]);
        }
Beispiel #4
0
        private void selfPrepare(int min_delay, int max_delay)
        {
            serverRemoteObjects = new Dictionary <string, IServerService>();
            matchIndexMap       = new Dictionary <string, int>();

            channel = new TcpChannel(_port);
            Console.WriteLine(_port.ToString());
            ChannelServices.RegisterChannel(channel, false);

            myRemoteObject = new ServerService(this, min_delay, max_delay);
            RemotingServices.Marshal(myRemoteObject, _name, typeof(ServerService)); //TODO remote object name
            fd = new FailureDetector();
            Console.WriteLine("Hello! I'm a Server at port " + _port);

            foreach (string url in ConfigurationManager.AppSettings.AllKeys)
            {
                string[] urlSplit = url.Split(new Char[] { '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
                int      portOut;
                Int32.TryParse(urlSplit[2], out portOut);
                //not to connect to himself
                if (portOut != _port)
                {
                    serverRemoteObjects.Add(url, (ServerService)Activator.GetObject(typeof(ServerService), url));
                    matchIndexMap.Add(url, 0);
                }
            }
            _numServers = serverRemoteObjects.Count;

            List <string> view = fd.getView();

            while (view == null || view.Count == 0)
            {
                Thread.Sleep(100);
                view = fd.getView();
            }
            _state = new FollowerState(this, 0);;
            Console.WriteLine("Finished constructing server " + _port + " with thread " + Thread.CurrentThread.ManagedThreadId);
        }
Beispiel #5
0
 public void setFailureDetector(FailureDetector f)
 {
     failureDetector = f;
 }