////////////////////////////////////////////////// ///// STRUCTORS ////////////////////////////////// public GameSession(string gameServerName, string gameServerAddress, double lifeSpan, IGamePortalServerController_Callback callbackChannel) : base(gameServerName, gameServerAddress, lifeSpan) { if (callbackChannel == null) { throw new ArgumentNullException("callbackChannel cannot be null"); } CallbackChannel = callbackChannel; PlayerList = new Dictionary <string, string>(); }
public string RegisterGameServer(string address, string serverName, out ECode ec) { ec = ECode.None; string token = null; bool collision = false; try { // Check for GameServer collisions // collision = (GameRegistry.IsPuidRegistered(serverName)); // Check if already registered if (collision == false) { // Check for server address collisions foreach (KeyValuePair <string, ClientSession> kvp in GameRegistry) { if (collision == false) // If no collision detected, check for collision { collision = (kvp.Value.ClientAddress == address); } } } if (collision) { ec = ECode.QueryError; Console.WriteLine("> GameServer registration collision: @ServerName:{" + serverName + "}"); } else { IGamePortalServerController_Callback callbackChannel = OperationContext.Current.GetCallbackChannel <IGamePortalServerController_Callback>(); GameSession session = new GameSession(serverName, address, GAME_LIFESPAN, callbackChannel); token = GameRegistry.RegisterClient(session); Console.WriteLine("> New GameServer registration: @ServerName:{" + serverName + "} token:{" + token + "}"); } } catch (ArgumentNullException) { // occurs if serverName or address is null ec = ECode.QueryError; } return(token); }