private void HandleMessage(RestDataRequestMessage message, ref RestResponse response) { var rawMessage = message.GetMessage(); Console.WriteLine($"Handle ${rawMessage.GetType().Name}"); switch (rawMessage) { case ChangeRegionMessage msg: HandleChangeRegion(msg, ref response); break; case ChangeGameTypesMessage msg: HandleChangeGameTypesMessage(msg, ref response); break; case GetServerStatusMessage msg: response.EnqueueMessage(new RestDataResponseMessage( new ServerStatusMessage(_context.Status))); response.SetSuccessful(true, "yes"); break; case ResponseCustomGameClientConnectionMessage msg: HandleResponseCustomGameClientConnectionMessage(msg, ref response, message); break; case RequestJoinCustomGameMessage msg: HandleRequestJoinCustomGameMessage(msg, ref response, message); break; default: Console.WriteLine($"Unhandled MessageType Message: ${message.GetMessage().GetType().Name}"); break; } }
private void HandleFunctions(RestDataRequestMessage message, ref RestResponse response) { var rawMsg = message.GetMessage(); Console.WriteLine($"Handle ${rawMsg.GetType().Name}"); switch (rawMsg) { case GetAnotherPlayerStateMessage msg: HandleGetAnotherPlayerStateMessage(msg, ref response, message); break; case GetPlayerBadgesMessage msg: HandleGetPlayerBadgesMessage(msg, ref response); break; case RequestCustomGameServerListMessage msg: HandleRequestCustomGameServerListMessage(msg, ref response); break; case RegisterCustomGameMessage msg: HandleRegisterCustomGameMessage(msg, ref response, message); break; case EndHostingCustomGameMessage msg: HandleEndHostingCustomGameMessage(msg, ref response, message); break; default: Console.WriteLine($"Unhandled MessageType Function: ${message.GetMessage().GetType().Name}"); break; } }
private void HandleLogins(RestDataRequestMessage message, ref RestResponse response, RestRequestMessage request) { var loginMessage = message.GetMessage() as InitializeSession; var session = new SessionCredentials(loginMessage.PeerId, SessionKey.NewGuid()); var playerdata = new PlayerData(); playerdata.FillWithNewPlayer(loginMessage.PlayerId, new [] { "FreeForAll", "Captain", "Siege", "Duel", "TeamDeathMatch", "FreeForAll" }); playerdata.LastPlayerName = loginMessage.PlayerName; playerdata.LastGameTypes = new[] { "Captain" }; var user = new User { Id = session, QueuedMessages = new Queue <RestResponseMessage>(), PlayerData = playerdata }; this._context.Users.Add(user); var initializeSessionResponse = new InitializeSessionResponse(playerdata, _context.Status); response.FunctionResult = new RestDataFunctionResult(new LoginResult(session.PeerId, session.SessionKey, initializeSessionResponse)); response.UserCertificate = session.SessionKey.ToByteArray(); response.SetSuccessful(true, "ResultFromServerTask"); }