Esempio n. 1
0
 public void GetPlayerLocation(string swid)
 {
     mt.send(SmartfoxCommand.GET_PLAYER_LOCATION, new Dictionary <string, SFSDataWrapper> {
         {
             "swid",
             SmartFoxGameServerClientShared.serialize(swid)
         }
     });
 }
Esempio n. 2
0
 public void SendRewardNotification(SignedResponse <RewardedUserCollectionJsonHelper> rewardCollection)
 {
     mt.send(SmartfoxCommand.SEND_EARNED_REWARDS, new Dictionary <string, SFSDataWrapper> {
         {
             "reward",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(rewardCollection))
         }
     });
 }
Esempio n. 3
0
 public void EquipDurable(SignedResponse <EquipDurableResponse> durable)
 {
     mt.send(SmartfoxCommand.EQUIP_DURABLE, new Dictionary <string, SFSDataWrapper> {
         {
             "type",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(durable))
         }
     });
 }
Esempio n. 4
0
 public void RefreshMembership(SignedResponse <MembershipRightsRefresh> rights)
 {
     mt.send(SmartfoxCommand.MEMBERSHIP_REFRESH, new Dictionary <string, SFSDataWrapper> {
         {
             "rights",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(rights))
         }
     });
 }
Esempio n. 5
0
 public void SetConsumableInventory(SignedResponse <ConsumableInventory> inventory)
 {
     mt.send(SmartfoxCommand.SET_CONSUMABLE_INVENTORY, new Dictionary <string, SFSDataWrapper> {
         {
             "data",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(inventory))
         }
     });
 }
Esempio n. 6
0
 public void EquipDispensable(int id)
 {
     mt.send(SmartfoxCommand.EQUIP_DISPENSABLE, new Dictionary <string, SFSDataWrapper> {
         {
             "type",
             SmartFoxGameServerClientShared.serialize(id)
         }
     });
 }
Esempio n. 7
0
 public void QuestSetQuestState(SignedResponse <QuestStateCollection> quests)
 {
     mt.send(SmartfoxCommand.SET_QUEST_STATES, new Dictionary <string, SFSDataWrapper> {
         {
             "data",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(quests))
         }
     });
 }
Esempio n. 8
0
 public void QuestCompleteObjective(string objective)
 {
     mt.send(SmartfoxCommand.COMPLETE_OBJECTIVE, new Dictionary <string, SFSDataWrapper> {
         {
             "obj",
             SmartFoxGameServerClientShared.serialize(objective)
         }
     });
 }
Esempio n. 9
0
 public void PrototypeSendAction(object data)
 {
     mt.send(SmartfoxCommand.PROTOTYPE, new Dictionary <string, SFSDataWrapper> {
         {
             "data",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(data))
         }
     });
 }
Esempio n. 10
0
 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)
         }
     });
 }
Esempio n. 11
0
 public void SendWebServiceEvent(SignedResponse <WebServiceEvent> wsEvent)
 {
     mt.send(SmartfoxCommand.WEBSERVICE_EVENT, new Dictionary <string, SFSDataWrapper> {
         {
             "d",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(wsEvent))
         }
     }, new object[1] {
         wsEvent.Data.type
     });
 }
Esempio n. 12
0
 public void ReuseConsumable(string type, object properties)
 {
     mt.send(SmartfoxCommand.REUSE_CONSUMABLE, new Dictionary <string, SFSDataWrapper>
     {
         {
             "type",
             SmartFoxGameServerClientShared.serialize(type)
         },
         {
             "prop",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(properties))
         }
     });
 }
Esempio n. 13
0
        private void fetchServerTimestamp(bool fetchEncryptionKeyAfterwards)
        {
            long      num       = timestampRequestCount++;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            timeStampRequests.Add(num, new TimeStampRequest(stopwatch, fetchEncryptionKeyAfterwards));
            mt.send(SmartfoxCommand.GET_SERVER_TIME, new Dictionary <string, SFSDataWrapper> {
                {
                    "ct",
                    SmartFoxGameServerClientShared.serialize(num)
                }
            });
        }
Esempio n. 14
0
 public void UseConsumable(SignedResponse <UsedConsumable> consumable, object properties)
 {
     mt.send(SmartfoxCommand.USE_CONSUMABLE, new Dictionary <string, SFSDataWrapper>
     {
         {
             "type",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(consumable))
         },
         {
             "prop",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(properties))
         }
     });
 }
Esempio n. 15
0
 public void Pickup(string id, string tag, Vector3 position)
 {
     mt.send(SmartfoxCommand.PICKUP, new Dictionary <string, SFSDataWrapper>
     {
         {
             "id",
             SmartFoxGameServerClientShared.serialize(id)
         },
         {
             "t",
             SmartFoxGameServerClientShared.serialize(tag)
         },
         {
             "p",
             SmartFoxGameServerClientShared.serialize(position)
         }
     });
 }
Esempio n. 16
0
 public void SendPartyGameSessionMessage(int sessionId, int type, object properties)
 {
     mt.send(SmartfoxCommand.PARTY_GAME_MESSAGE, new Dictionary <string, SFSDataWrapper>
     {
         {
             "id",
             SmartFoxGameServerClientShared.serialize(sessionId)
         },
         {
             "type",
             SmartFoxGameServerClientShared.serialize(type)
         },
         {
             "message",
             SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(properties))
         }
     });
 }
Esempio n. 17
0
        private void fetchEncryptionKey()
        {
            RSAParameters value = mt.ClubPenguinClient.CPKeyValueDatabase.GetRsaParameters().Value;
            string        str   = Convert.ToBase64String(value.Exponent);
            string        str2  = Convert.ToBase64String(value.Modulus);

            mt.send(SmartfoxCommand.GET_ROOM_ENCRYPTION_KEY, new Dictionary <string, SFSDataWrapper>
            {
                {
                    "pkm",
                    SmartFoxGameServerClientShared.serialize(str2)
                },
                {
                    "pke",
                    SmartFoxGameServerClientShared.serialize(str)
                }
            });
        }
Esempio n. 18
0
        public void SendChatMessage(SignedResponse <ChatMessage> signedChatMessage)
        {
            Dictionary <string, SFSDataWrapper> dictionary = new Dictionary <string, SFSDataWrapper>();

            dictionary.Add("msg", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(signedChatMessage)));
            Dictionary <string, SFSDataWrapper> parameters = dictionary;

            if (mt.SmartFoxEncryptor != null)
            {
                try
                {
                    mt.SmartFoxEncryptor.EncryptParameter("msg", parameters);
                }
                catch (Exception ex)
                {
                    Log.LogErrorFormatted(this, "Failed to encrypt parameter. Exception: {0}", ex);
                    Log.LogException(this, ex);
                }
            }
            mt.send(SmartfoxCommand.CHAT, parameters);
        }
Esempio n. 19
0
        private LocomotionActionEvent locomotionActionEventFromProps(int playerId, ISFSObject props)
        {
            LocomotionActionEvent result = default(LocomotionActionEvent);

            result.SessionId = getSessionId(playerId);
            result.Type      = (LocomotionAction)props.GetByte("a");
            result.Position  = SmartFoxGameServerClientShared.deserializeVec3(props, "p");
            result.Timestamp = props.GetLong("t");
            if (props.ContainsKey("d"))
            {
                result.Direction = SmartFoxGameServerClientShared.deserializeVec3(props, "d");
            }
            if (props.ContainsKey("v"))
            {
                result.Velocity = SmartFoxGameServerClientShared.deserializeVec3(props, "v");
            }
            if (props.ContainsKey("o"))
            {
                result.Object = mt.JsonService.Deserialize <ActionedObject>(props.GetUtfString("o"));
            }
            return(result);
        }
Esempio n. 20
0
        public void TriggerLocomotionAction(LocomotionActionEvent action, bool droppable)
        {
            Dictionary <string, SFSDataWrapper> dictionary = new Dictionary <string, SFSDataWrapper>();

            dictionary.Add("a", SmartFoxGameServerClientShared.serialize((byte)action.Type));
            dictionary.Add("p", SmartFoxGameServerClientShared.serialize(action.Position));
            dictionary.Add("t", SmartFoxGameServerClientShared.serialize(ServerTime));
            Dictionary <string, SFSDataWrapper> dictionary2 = dictionary;

            if (action.Direction.HasValue)
            {
                dictionary2.Add("d", SmartFoxGameServerClientShared.serialize(action.Direction.Value));
            }
            if (action.Velocity.HasValue)
            {
                dictionary2.Add("v", SmartFoxGameServerClientShared.serialize(action.Velocity.Value));
            }
            if (action.Object != null)
            {
                dictionary2.Add("o", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(action.Object)));
            }
            mt.send(SmartfoxCommand.LOCOMOTION_ACTION, dictionary2, null, droppable);
        }
Esempio n. 21
0
        private void onExtensionResponse(BaseEvent evt)
        {
            try
            {
                ISFSObject iSFSObject = (ISFSObject)evt.Params["params"];
                if (mt.SmartFoxEncryptor != null)
                {
                    mt.SmartFoxEncryptor.DecryptParameters(iSFSObject);
                }
                int?userId = null;
                if (iSFSObject.ContainsKey("senderId"))
                {
                    userId = iSFSObject.GetInt("senderId");
                }
                SmartfoxCommand?smartfoxCommand = SmartFoxCommand.FromString((string)evt.Params["cmd"]);
                if (!smartfoxCommand.HasValue)
                {
                    return;
                }
                object          data            = null;
                GameServerEvent?gameServerEvent = null;
                switch (smartfoxCommand.Value)
                {
                case SmartfoxCommand.CHAT_ACTIVITY:
                    gameServerEvent = GameServerEvent.CHAT_ACTIVITY_RECEIVED;
                    data            = getSessionId(userId);
                    break;

                case SmartfoxCommand.CHAT_ACTIVITY_CANCEL:
                    gameServerEvent = GameServerEvent.CHAT_ACTIVITY_CANCEL_RECEIVED;
                    data            = getSessionId(userId);
                    break;

                case SmartfoxCommand.CHAT:
                    gameServerEvent = GameServerEvent.CHAT_MESSAGE_RECEIVED;
                    data            = mt.JsonService.Deserialize <ReceivedChatMessage>(iSFSObject.GetUtfString("msg"));
                    break;

                case SmartfoxCommand.GET_SERVER_TIME:
                    timeStampRecieved(iSFSObject.GetLong("ct"), iSFSObject.GetLong("st"));
                    break;

                case SmartfoxCommand.SERVER_TIME_ERROR:
                    fetchServerTimestamp(fetchEncryptionKeyAfterwards: false);
                    break;

                case SmartfoxCommand.GET_ROOM_ENCRYPTION_KEY:
                    encryptionKeyReceived(iSFSObject.GetUtfString("ek"));
                    break;

                case SmartfoxCommand.ENCRYPTION_KEY_ERROR:
                    Log.LogError(this, "Failed to get room encryption key.");
                    mt.teardown();
                    gameServerEvent = GameServerEvent.ROOM_JOIN_ERROR;
                    data            = null;
                    break;

                case SmartfoxCommand.LOCOMOTION_ACTION:
                    gameServerEvent = GameServerEvent.USER_LOCO_ACTION;
                    data            = locomotionActionEventFromProps(userId.Value, iSFSObject);
                    break;

                case SmartfoxCommand.PROTOTYPE:
                {
                    gameServerEvent = GameServerEvent.PROTOTYPE_ACTION;
                    PrototypeAction prototypeAction = default(PrototypeAction);
                    prototypeAction.userid = getSessionId(userId);
                    prototypeAction.data   = JsonMapper.ToObject(iSFSObject.GetUtfString("data"));
                    data = prototypeAction;
                    break;
                }

                case SmartfoxCommand.SERVER_OBJECTIVE_COMPLETED:
                    gameServerEvent = GameServerEvent.QUEST_OBJECTIVES_UPDATED;
                    data            = mt.JsonService.Deserialize <SignedResponse <QuestObjectives> >(iSFSObject.GetUtfString("data"));
                    break;

                case SmartfoxCommand.SERVER_QUEST_ERROR:
                    gameServerEvent = GameServerEvent.QUEST_ERROR;
                    data            = null;
                    break;

                case SmartfoxCommand.SET_QUEST_STATES:
                    gameServerEvent = GameServerEvent.QUEST_DATA_SYNCED;
                    data            = null;
                    break;

                case SmartfoxCommand.USE_CONSUMABLE:
                {
                    gameServerEvent = GameServerEvent.CONSUMABLE_USED;
                    ConsumableEvent consumableEvent = default(ConsumableEvent);
                    consumableEvent.SessionId = getSessionId(userId);
                    consumableEvent.Type      = iSFSObject.GetUtfString("type");
                    data = consumableEvent;
                    break;
                }

                case SmartfoxCommand.REUSE_FAILED:
                {
                    gameServerEvent = GameServerEvent.CONSUMABLE_REUSE_FAILED;
                    ConsumableUseFailureEvent consumableUseFailureEvent = default(ConsumableUseFailureEvent);
                    consumableUseFailureEvent.Type       = iSFSObject.GetUtfString("type");
                    consumableUseFailureEvent.Properties = JsonMapper.ToObject(iSFSObject.GetUtfString("prop"));
                    data = consumableUseFailureEvent;
                    break;
                }

                case SmartfoxCommand.CONSUMABLE_MMO_DEPLOYED:
                    if (iSFSObject.ContainsKey("ownerId") && iSFSObject.ContainsKey("senderId"))
                    {
                        gameServerEvent = GameServerEvent.CONSUMABLE_MMO_DEPLOYED;
                        ConsumableMMODeployedEvent consumableMMODeployedEvent = default(ConsumableMMODeployedEvent);
                        consumableMMODeployedEvent.SessionId    = getSessionId(iSFSObject.GetInt("ownerId"));
                        consumableMMODeployedEvent.ExperienceId = iSFSObject.GetInt("senderId");
                        data = consumableMMODeployedEvent;
                    }
                    break;

                case SmartfoxCommand.SET_CONSUMABLE_PARTIAL_COUNT:
                    gameServerEvent = GameServerEvent.COMSUMBLE_PARTIAL_COUNT_SET;
                    data            = mt.JsonService.Deserialize <SignedResponse <UsedConsumable> >(iSFSObject.GetUtfString("data"));
                    break;

                case SmartfoxCommand.RECEIVED_REWARDS:
                    gameServerEvent = GameServerEvent.RECEIVED_REWARDS;
                    data            = mt.JsonService.Deserialize <SignedResponse <RewardedUserCollectionJsonHelper> >(iSFSObject.GetUtfString("reward"));
                    break;

                case SmartfoxCommand.RECEIVED_REWARDS_DELAYED:
                    gameServerEvent = GameServerEvent.RECEIVED_REWARDS_DELAYED;
                    data            = mt.JsonService.Deserialize <SignedResponse <RewardedUserCollectionJsonHelper> >(iSFSObject.GetUtfString("reward"));
                    break;

                case SmartfoxCommand.RECEIVED_ROOOM_REWARDS:
                    gameServerEvent = GameServerEvent.RECEIVED_ROOOM_REWARDS;
                    data            = mt.JsonService.Deserialize <SignedResponse <InRoomRewards> >(iSFSObject.GetUtfString("reward"));
                    break;

                case SmartfoxCommand.PROGRESSION_LEVELUP:
                {
                    gameServerEvent = GameServerEvent.LEVELUP;
                    UserLevelUpEvent userLevelUpEvent = default(UserLevelUpEvent);
                    userLevelUpEvent.SessionId = getSessionId(userId);
                    userLevelUpEvent.Level     = iSFSObject.GetInt("level");
                    data = userLevelUpEvent;
                    break;
                }

                case SmartfoxCommand.ROOM_TRANSIENT_DATA:
                    mt.LastRoomTransientData = mt.JsonService.Deserialize <SignedResponse <TransientData> >(iSFSObject.GetUtfString("d"));
                    break;

                case SmartfoxCommand.TASK_COUNT:
                {
                    gameServerEvent = GameServerEvent.TASK_COUNT_UPDATED;
                    TaskProgress taskProgress = default(TaskProgress);
                    taskProgress.taskId  = iSFSObject.GetUtfString("t");
                    taskProgress.counter = iSFSObject.GetInt("c");
                    data = taskProgress;
                    break;
                }

                case SmartfoxCommand.TASK_PROGRESS:
                    gameServerEvent = GameServerEvent.TASK_PROGRESS_UPDATED;
                    data            = mt.JsonService.Deserialize <SignedResponse <TaskProgress> >(iSFSObject.GetUtfString("d"));
                    break;

                case SmartfoxCommand.GET_SIGNED_STATE:
                    gameServerEvent = GameServerEvent.STATE_SIGNED;
                    data            = mt.JsonService.Deserialize <SignedResponse <InWorldState> >(iSFSObject.GetUtfString("data"));
                    break;

                case SmartfoxCommand.GET_PLAYER_LOCATION:
                    gameServerEvent = GameServerEvent.PLAYER_LOCATION_RECEIVED;
                    data            = SmartFoxGameServerClientShared.deserializeVec3(iSFSObject, "pos");
                    break;

                case SmartfoxCommand.PLAYER_NOT_FOUND:
                    gameServerEvent = GameServerEvent.PLAYER_NOT_FOUND;
                    break;

                case SmartfoxCommand.PARTY_GAME_START:
                    gameServerEvent = GameServerEvent.PARTY_GAME_START;
                    data            = partyGameStartEventFromProps(iSFSObject);
                    break;

                case SmartfoxCommand.PARTY_GAME_START_V2:
                    gameServerEvent = GameServerEvent.PARTY_GAME_START_V2;
                    data            = partyGameStartEventV2FromProps(iSFSObject);
                    break;

                case SmartfoxCommand.PARTY_GAME_END:
                    gameServerEvent = GameServerEvent.PARTY_GAME_END;
                    data            = partyGameEndEventFromProps(iSFSObject);
                    break;

                case SmartfoxCommand.PARTY_GAME_MESSAGE:
                    gameServerEvent = GameServerEvent.PARTY_GAME_MESSAGE;
                    data            = partyGameMessageEventFromProps(iSFSObject);
                    break;

                case SmartfoxCommand.IGLOO_UPDATED:
                    gameServerEvent = GameServerEvent.IGLOO_UPDATED;
                    data            = iSFSObject.GetUtfString("igloo_id");
                    break;

                case SmartfoxCommand.FORCE_LEAVE:
                    gameServerEvent = GameServerEvent.FORCE_LEAVE;
                    data            = mt.JsonService.Deserialize <ZoneId>(iSFSObject.GetUtfString("zone_id"));
                    break;
                }
                if (gameServerEvent.HasValue)
                {
                    mt.triggerEvent(gameServerEvent.Value, data);
                }
            }
            catch (JsonException ex)
            {
                Log.LogNetworkError(this, "Error occurred getting data from SFS: " + ex.Message);
            }
        }
Esempio n. 22
0
 public SmartFoxGameServerClient(ClubPenguinClient clubPenguinClient, string gameZone, bool gameEncryption, bool gameDebugging, bool lagMonitoring)
 {
     mt = new SmartFoxGameServerClientShared(clubPenguinClient, gameZone, gameEncryption, gameDebugging, lagMonitoring);
     CoroutineRunner.StartPersistent(processMessagesCoroutine(), this, "Smartfox message procession");
 }
Esempio n. 23
0
 internal SmartFoxGameServerClientSFSThread(SmartFoxGameServerClientShared smartFoxGameServerClientShared)
 {
     mt = smartFoxGameServerClientShared;
 }