예제 #1
0
        public void reset()
        {
            //reset every server, each server resets all his clients
            foreach (KeyValuePair <string, ServerInfo> pair in serverList)
            {
                IServerPuppeteer server = (IServerPuppeteer)Activator.GetObject(
                    typeof(IServerPuppeteer),
                    pair.Value.url_puppeteer);
                Action action = new Action(server.kill);
                action.BeginInvoke(null, null);
                Log.Debug("killed server {server}", pair.Value.server_id);
            }
            serverList.Clear();

            //reset clients
            foreach (KeyValuePair <string, ClientInfo> pair in clientList)
            {
                IClientPuppeteer client = (IClientPuppeteer)Activator.GetObject(
                    typeof(IClientPuppeteer),
                    pair.Value.client_url_puppeteer);
                Action action = new Action(client.kill);
                action.BeginInvoke(null, null);
                Log.Debug("killed client {client}", pair.Value.username);
            }
            clientList.Clear();

            //reset locations
            locationList.Clear();
        }
예제 #2
0
 public void status()
 {
     //make all servers and clients print status
     //foreach servers
     foreach (KeyValuePair <string, ServerInfo> pair in serverList)
     {
         IServerPuppeteer server = (IServerPuppeteer)Activator.GetObject(
             typeof(IServerPuppeteer),
             pair.Value.url_puppeteer);
         try{
             server.statusPuppeteer();
         } catch (Exception ex) {
             Log.Error(ex, "error while showing server status");
         }
     }
     //foreach clients
     foreach (KeyValuePair <string, ClientInfo> pair in clientList)
     {
         IClientPuppeteer client = (IClientPuppeteer)Activator.GetObject(
             typeof(IClientPuppeteer),
             pair.Value.client_url_puppeteer);
         try{
             client.statusPuppeteer();
         }catch (Exception ex) {
             Log.Error(ex, "error while showing client status");
         }
     }
 }
예제 #3
0
        public void addRoom(string location_name, string capacity, string room_name)
        {
            //look for location
            Location location;

            if (locationList.ContainsKey(location_name))
            {
                location = locationList[location_name];
            }
            else
            {
                location = new Location(location_name);
                locationList.Add(location_name, location);
            }

            //create room
            location.addRoom(room_name, Int32.Parse(capacity));

            //send room to all servers
            foreach (KeyValuePair <string, ServerInfo> pair in serverList)
            {
                IServerPuppeteer server = (IServerPuppeteer)Activator.GetObject(
                    typeof(IServerPuppeteer),
                    pair.Value.url_puppeteer);
                server.addRoom(location_name, Int32.Parse(capacity), room_name);
            }
        }
예제 #4
0
        public void unfreezeServer(string server_id)
        {
            //unfreeze server
            ServerInfo       serverInfo = serverList[server_id];
            IServerPuppeteer server     = (IServerPuppeteer)Activator.GetObject(
                typeof(IServerPuppeteer),
                serverInfo.url_puppeteer);

            server.unfreeze();
        }
예제 #5
0
        public ServerInfo crashServer(string server_id)
        {
            //get server
            ServerInfo       serverInfo = serverList[server_id];
            IServerPuppeteer server     = (IServerPuppeteer)Activator.GetObject(
                typeof(IServerPuppeteer),
                serverInfo.url_puppeteer);

            //async crash
            Action action = new Action(server.kill);

            action.BeginInvoke(null, null);

            //remove evidence of server
            serverList.Remove(server_id);
            return(serverInfo);
        }
예제 #6
0
        public void undoAll()
        {
            foreach (KeyValuePair <string, ServerInfo> pair in serverList)
            {
                IServerPuppeteer server = (IServerPuppeteer)Activator.GetObject(
                    typeof(IServerPuppeteer),
                    pair.Value.url_puppeteer);
                server.undo();
            }

            //reset clients
            foreach (KeyValuePair <string, ClientInfo> pair in clientList)
            {
                IClientPuppeteer client = (IClientPuppeteer)Activator.GetObject(
                    typeof(IClientPuppeteer),
                    pair.Value.client_url_puppeteer);
                client.undo();
            }

            locationList.Clear();
        }
예제 #7
0
        public ServerInfo createServer(string server_id, string server_url, string max_faults,
                                       string min_delay, string max_delay)
        {
            //tcp://localhost:3000/server1 needs to be parsed
            //connect to correct pcs
            string[] urlParsed = server_url.Split(':');
            string   pcsUrl    = urlParsed[0] + ':' + urlParsed[1] + ':' + "10000/PCS";
            IPCS     pcs       = (IPCS)Activator.GetObject(typeof(IPCS), pcsUrl);

            //create server
            ServerInfo serverInfo;

            try{
                serverInfo = pcs.createServer(server_id, server_url,
                                              max_faults, min_delay, max_delay);
            } catch (Exception ex) {
                //TODO catch PCS types of execeptions
                Log.Error(ex, "pcs connection failed");
                throw new PCSException("pcs connection failed", ex);
            }
            //save server
            serverList.Add(server_id, serverInfo);

            //send all available rooms
            IServerPuppeteer server = (IServerPuppeteer)Activator.GetObject(
                typeof(IServerPuppeteer),
                serverInfo.url_puppeteer);

            try{
                //Thread.Sleep(50); //TODO: make async
                server.populate(locationList, serverList);
            } catch (Exception ex) {
                Log.Error(ex, "connection to server failed");
            }

            return(serverInfo);
        }