private void ProcessProfileCreateCharacterRequest(RequestSetup requestInProcess) { ProfileCreateCharacterRequest request = requestInProcess.request as ProfileCreateCharacterRequest; int characterId = accountQuerier.CreateCharacterProfile( request.accountId, request.productName.MakeString(), request.characterName.MakeString(), request.state); if (characterId == -1) { // We could return a result here - however the game server could request a load, and when that fails it'll know something is up Console.Error.WriteLine("Failed to create new character: accountId: {0}, productName: {1}, characterName: {2}, state: {3}", request.accountId, request.productName, request.characterName, request.state); } ProfileCreateCharacterResponse response = (ProfileCreateCharacterResponse)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterResponse); response.accountId = request.accountId; response.characterId = characterId; ConnectionState cs = connections[requestInProcess.connectionId]; cs.Send(response); }
private void CreateCharacterResponsePacket(ProfileCreateCharacterResponse packet) { if (saveState == null) { Debug.LogFormat("Unable to update player state, as it doesn't exist: entityId: {0}, accountId: {1}", EntityId, AccountId); return; } // This may have a characterId of NO_CHARACTER_ID if the insert failed saveState.characterId = packet.characterId; return; }
private void CreateFakeResponse(BasePacket packet) { // Fake a response ProfileCreateCharacterRequest request = packet as ProfileCreateCharacterRequest; if (request != null) { ProfileCreateCharacterResponse response = (ProfileCreateCharacterResponse)IntrepidSerialize.TakeFromPool(PacketType.ProfileCreateCharacterResponse); response.accountId = request.accountId; response.characterId = fakeCharacterId++; lock (packetLock) { incomingPackets.Enqueue(response); } } }
private void ProfileServer_OnReceivePacket(BasePacket packet) { ProfileCreateCharacterResponse response = packet as ProfileCreateCharacterResponse; if (response != null) { // Find the player by accountId // TODO: Have players indexed by accountId somewhere? foreach (var client in connectedClients) { if (client.Value.AccountId == response.accountId) { client.Value.AddIncomingPacket(response); break; } } } }