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(); }
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"); } } }
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); } }
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(); }
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); }
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(); }
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); }