private void refreshSFSRights(SignedResponse <MembershipRightsRefresh> signedRights) { if (signedRights != null) { clubPenguinClient.GameServer.RefreshMembership(signedRights); } }
public void JoinRoom(SignedResponse <JoinRoomData> signedJoinRoomData) { mt.SignedJoinRoomData = signedJoinRoomData; waitForRoomJoinEvent = true; if (!mt.isConnected) { mt.connect(signedJoinRoomData.Data.host, signedJoinRoomData.Data.tcpPort, signedJoinRoomData.Data.httpsPort); return; } if (!mt.isLoggedIn) { mt.login(); return; } string clientRoomName = mt.ClientRoomName; if (clientRoomName != null && clientRoomName == signedJoinRoomData.Data.room) { mt.triggerEvent(GameServerEvent.ROOM_JOIN, clientRoomName); return; } RoomJoinError roomJoinError = default(RoomJoinError); roomJoinError.roomName = signedJoinRoomData.Data.room; roomJoinError.errorMessage = "Already logged in"; mt.triggerEvent(GameServerEvent.ROOM_JOIN_ERROR, roomJoinError); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { CustomEquipmentCollection customEquipmentCollection = offlineDatabase.Read <CustomEquipmentCollection>(); ClubPenguin.Net.Offline.PlayerOutfitDetails value = default(ClubPenguin.Net.Offline.PlayerOutfitDetails); value.Init(); long[] parts = RequestBody.parts; foreach (long num in parts) { foreach (CustomEquipment item in customEquipmentCollection.Equipment) { CustomEquipment current = item; if (current.equipmentId == num) { value.Parts.Add(current); break; } } } offlineDatabase.Write(value); ResponseBody = new SignedResponse <ClubPenguin.Net.Domain.PlayerOutfitDetails> { Data = new ClubPenguin.Net.Domain.PlayerOutfitDetails { parts = value.Parts.ToArray() } }; }
private void onIglooDataUpdated(UpdateIglooDataOperation operation, HttpResponse httpResponse) { SignedResponse <IglooData> signedResponseBody = operation.SignedResponseBody; clubPenguinClient.GameServer.SendIglooUpdated(signedResponseBody); Service.Get <EventDispatcher>().DispatchEvent(new IglooServiceEvents.IglooDataUpdated(signedResponseBody)); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { ResponseBody = new SignedResponse <QuestStateCollection> { Data = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: false) }; }
public static SignedResponse <JoinRoomData> JoinRoom(string world, string language, ZoneId zoneId, OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { Dictionary <string, long> earnedRewards = new Dictionary <string, long>(); foreach (ClubPenguin.Net.Offline.InRoomRewards.InRoomReward item in offlineDatabase.Read <ClubPenguin.Net.Offline.InRoomRewards>().Collected) { if (item.Room == zoneId.name) { earnedRewards = item.Collected; break; } } ClubPenguin.Net.Offline.Profile profile = offlineDatabase.Read <ClubPenguin.Net.Offline.Profile>(); PlayerRoomData playerRoomData = default(PlayerRoomData); playerRoomData.assets = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>().Assets; playerRoomData.consumableInventory = new ClubPenguin.Net.Domain.ConsumableInventory { inventoryMap = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>().Inventory }; playerRoomData.dailyTaskProgress = new TaskProgressList(); playerRoomData.member = true; playerRoomData.outfit = new ClubPenguin.Net.Domain.PlayerOutfitDetails { parts = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerOutfitDetails>().Parts.ToArray() }; playerRoomData.profile = new ClubPenguin.Net.Domain.Profile { colour = profile.Colour, daysOld = profile.DaysOld }; playerRoomData.quests = SetProgressOperation.GetQuestStateCollection(offlineDatabase.Read <QuestStates>(), offlineDefinitions, includeComplete: true); PlayerRoomData playerRoomData2 = playerRoomData; RoomIdentifier roomIdentifier = new RoomIdentifier(world, LocalizationLanguage.GetLanguageFromLanguageString(language), zoneId, new ContentIdentifier("1.13.0", "offline", DateTime.UtcNow.ToString("yyyy-MM-dd"), "NONE").ToString()); int equippedTubeId = offlineDatabase.Read <TubeData>().EquippedTubeId; Random random = new Random(); byte[] array = new byte[8]; random.NextBytes(array); SignedResponse <JoinRoomData> signedResponse = new SignedResponse <JoinRoomData>(); signedResponse.Data = new JoinRoomData { earnedRewards = earnedRewards, membershipRights = new MembershipRights { member = true }, playerRoomData = playerRoomData2, room = roomIdentifier.ToString(), selectedTubeId = equippedTubeId, sessionId = Math.Abs(BitConverter.ToInt64(array, 0)), host = Service.Get <ICommonGameSettings>().GameServerHost, tcpPort = 9933, userName = offlineDatabase.Read <RegistrationProfile>().userName, swid = offlineDatabase.AccessToken }; signedResponse.swid = offlineDatabase.AccessToken; return(signedResponse); }
private void onRewardsReceivedDelayed(GameServerEvent gameServerEvent, object data) { SignedResponse <RewardedUserCollectionJsonHelper> signedResponse = (SignedResponse <RewardedUserCollectionJsonHelper>)data; RewardedUserCollection key = signedResponse.Data.toRewardedUserCollection(); delayedRewards.Add(key, signedResponse); }
private void outfitChangeComplete(SetOutfitOperation operation, HttpResponse httpResponse) { SignedResponse <PlayerOutfitDetails> responseBody = operation.ResponseBody; clubPenguinClient.GameServer.SetOutfit(responseBody); Service.Get <EventDispatcher>().DispatchEvent(default(PlayerStateServiceEvents.PlayerOutfitSaved)); }
private bool onClaimDelayedReward(RewardServiceEvents.ClaimDelayedReward evt) { bool flag = false; foreach (KeyValuePair <RewardedUserCollection, SignedResponse <RewardedUserCollectionJsonHelper> > delayedReward in delayedRewards) { if (delayedReward.Key.source == evt.Source && delayedReward.Key.sourceId == evt.SourceId) { RewardedUserCollection key = delayedReward.Key; SignedResponse <RewardedUserCollectionJsonHelper> value = delayedReward.Value; if (key.rewards.ContainsKey(clubPenguinClient.PlayerSessionId)) { APICall <AddRewardOperation> aPICall = clubPenguinClient.RewardApi.AddReward(value); aPICall.OnResponse += onAssetsSet; aPICall.OnError += handleCPResponseError; aPICall.Execute(); } Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.RewardsEarned(key)); delayedRewards.Remove(key); flag = true; break; } } if (!flag) { } return(false); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { ResponseBody = new SignedResponse <ChatMessage> { Data = RequestBody }; }
public void RpcClient_Can_Handle_SignMessageResponse(SignedResponse signedResponse) { var testScheduler = new TestScheduler(); var signMessageResponse = new SignMessageResponse { OriginalMessage = signedResponse.OriginalMessage, PublicKey = signedResponse.PublicKey, Signature = signedResponse.Signature, }; var correlationId = CorrelationId.GenerateCorrelationId(); var protocolMessage = signMessageResponse.ToProtocolMessage(PeerIdHelper.GetPeerId("sender"), correlationId); var messageStream = MessageStreamHelper.CreateStreamWithMessage(_fakeContext, testScheduler, protocolMessage ); _handler = new SignMessageResponseObserver(_output, _logger); _handler.StartObserving(messageStream); testScheduler.Start(); _output.Received(1).WriteLine(Arg.Any <string>()); }
private static void exportSignedResponse(SignedResponse <T> obj, JsonWriter writer) { writer.WriteObjectStart(); writer.WritePropertyName("goodUntil"); writer.Write(obj.goodUntil); writer.WritePropertyName("signature"); writer.Write(obj.signature); writer.WritePropertyName("swid"); writer.Write(obj.swid); writer.WritePropertyName("data"); ICommonGameSettings commonGameSettings = Service.Get <ICommonGameSettings>(); if (commonGameSettings.OfflineMode && !string.IsNullOrEmpty(commonGameSettings.GameServerHost)) { writer.WriteRaw(JsonMapper.ToJson(obj.Data)); } else if (obj._rawJson != null) { writer.WriteRaw(obj._rawJson.ToJson()); } else { writer.Write(""); } writer.WriteObjectEnd(); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { SignedJoinRoomData = JoinRoom(World, Language, new ZoneId { name = Room }, offlineDatabase, offlineDefinitions); }
private void onConsumablePartialCountSet(GameServerEvent gameServerEvent, object data) { SignedResponse <UsedConsumable> partial = (SignedResponse <UsedConsumable>)data; APICall <StorePartialConsumableOperation> aPICall = clubPenguinClient.ConsumableApi.StorePartialConsumable(partial); aPICall.OnResponse += onStorePartialConsumableComplete; aPICall.Execute(); }
public void CatchFish(SignedResponse <FishingResult> fish, string winningRewardName) { APICall <FishingCatchOperation> aPICall = clubPenguinClient.MinigameApi.FishingCatch(fish, winningRewardName); aPICall.OnComplete += onFishingRewardGranted; aPICall.OnError += handleCPResponseError; aPICall.Execute(); }
private void onTaskProgressUpdated(GameServerEvent gameServerEvent, object data) { SignedResponse <TaskProgress> progress = (SignedResponse <TaskProgress>)data; APICall <SetTaskProgressOperation> aPICall = clubPenguinClient.TaskApi.SetProgress(progress); aPICall.OnError += handleCPResponseError; aPICall.Execute(); }
private void questDataReturned(SignedResponse <QuestStateCollection> data) { if (clubPenguinClient.GameServer.CurrentRoom() == null) { PendingQuestUpdateEvent item = default(PendingQuestUpdateEvent); item.eventType = EventType.SYNC_WITH_GAME_SERVER; item.syncData = data; requests.Enqueue(item); processingRequest = false; return; } clubPenguinClient.GameServer.QuestSetQuestState(data); QuestStateCollection questStateCollection = new QuestStateCollection(); questStateCollection.AddRange(data.Data); QuestStateCollection questStateCollection2 = new QuestStateCollection(); foreach (PendingQuestUpdateEvent request in requests) { PendingQuestUpdateEvent current = request; switch (current.eventType) { case EventType.STATUS_UPDATE: for (int i = 0; i < questStateCollection.Count; i++) { if (questStateCollection[i].questId == current.questId) { questStateCollection[i].status = current.status; if (current.status == QuestStatus.COMPLETED) { questStateCollection2.Add(questStateCollection[i]); } } } break; case EventType.PROGRESS_UPDATE: for (int i = 0; i < questStateCollection.Count; i++) { if (questStateCollection[i].status == QuestStatus.ACTIVE) { if (questStateCollection[i].completedObjectives == null) { questStateCollection[i].completedObjectives = new QuestObjectives(); } questStateCollection[i].completedObjectives.Add(current.objective); break; } } break; } } for (int i = 0; i < questStateCollection2.Count; i++) { questStateCollection.Remove(questStateCollection2[i]); } Service.Get <EventDispatcher>().DispatchEvent(new QuestServiceEvents.QuestStatesRecieved(questStateCollection)); }
public void SetProfile(SignedResponse <Profile> profile) { updateUserVars(new Dictionary <SocketUserVars, object> { { SocketUserVars.PROFILE, mt.JsonService.Serialize(profile) } }); }
public void QuestSetQuestState(SignedResponse <QuestStateCollection> quests) { mt.send(SmartfoxCommand.SET_QUEST_STATES, new Dictionary <string, SFSDataWrapper> { { "data", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(quests)) } }); }
public void SetConsumableInventory(SignedResponse <ConsumableInventory> inventory) { mt.send(SmartfoxCommand.SET_CONSUMABLE_INVENTORY, new Dictionary <string, SFSDataWrapper> { { "data", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(inventory)) } }); }
public void EquipDurable(SignedResponse <EquipDurableResponse> durable) { mt.send(SmartfoxCommand.EQUIP_DURABLE, new Dictionary <string, SFSDataWrapper> { { "type", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(durable)) } }); }
public void RefreshMembership(SignedResponse <MembershipRightsRefresh> rights) { mt.send(SmartfoxCommand.MEMBERSHIP_REFRESH, new Dictionary <string, SFSDataWrapper> { { "rights", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(rights)) } }); }
public void SendRewardNotification(SignedResponse <RewardedUserCollectionJsonHelper> rewardCollection) { mt.send(SmartfoxCommand.SEND_EARNED_REWARDS, new Dictionary <string, SFSDataWrapper> { { "reward", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(rewardCollection)) } }); }
public void SetSelectedTube(SignedResponse <EquipTubeResponse> tube) { updateUserVars(new Dictionary <SocketUserVars, object> { { SocketUserVars.SELECTED_TUBE, mt.JsonService.Serialize(tube) } }); }
public void SetOutfit(SignedResponse <PlayerOutfitDetails> outfit) { updateUserVars(new Dictionary <SocketUserVars, object> { { SocketUserVars.OUTFIT, mt.JsonService.Serialize(outfit) } }); }
public void SendIglooUpdated(SignedResponse <IglooData> signedIglooData) { mt.send(SmartfoxCommand.IGLOO_UPDATED, new Dictionary <string, SFSDataWrapper> { { "igloo_data", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(signedIglooData), asText: true) } }); }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { SignedEquipDurableResponse = new SignedResponse <EquipDurableResponse> { Data = new EquipDurableResponse { propId = propId } }; }
protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions) { SignedFishingResult = new SignedResponse <FishingResult> { Data = new FishingResult { availablePrizeMap = offlineDefinitions.GetRandomFishingPrizes() } }; }
private void onObjectiveCompleted(GameServerEvent gameServerEvent, object data) { SignedResponse <QuestObjectives> progress = (SignedResponse <QuestObjectives>)data; APICall <SetProgressOperation> aPICall = clubPenguinClient.QuestApi.SetProgress(progress); aPICall.OnResponse += objectiveCompleteQuestDataReturned; aPICall.OnError += handleRequestError; aPICall.OnError += onQuestProgressionError; aPICall.Execute(); }
private void onRoomRewardsReceived(GameServerEvent gameServerEvent, object data) { SignedResponse <InRoomRewards> signedResponse = (SignedResponse <InRoomRewards>)data; APICall <AddRoomRewardsOperation> aPICall = clubPenguinClient.RewardApi.AddRoomRewards(signedResponse); aPICall.OnResponse += onAssetsSet; aPICall.OnError += handleCPResponseError; aPICall.Execute(); Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.RoomRewardsReceived(signedResponse.Data.room, signedResponse.Data.collected)); }