Beispiel #1
0
        public void ResetSession()
        {
            gameToken     = null;
            cipherDataDic = new Dictionary <CipherType, Cipher>();
            hmacDataDic   = new Dictionary <string, string>();

            NMGPlayerPrefs.SetChannelKey(NMGChannel.EveryNetmarble, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.Facebook, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.Kakao, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.Google, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.GameCenter, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.Naver, null);
            NMGPlayerPrefs.SetChannelKey(NMGChannel.Twitter, null);
            NMGPlayerPrefs.SetRegion(null);

            if (Configuration.GetUseFixedPlayerID())
            {
                // TODO FixedPlayerID
            }
            else
            {
                playerId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                NMGPlayerPrefs.SetPlayerId(playerId);
                Log.Debug("[NMGPlayMode.SessionManager] Save new PlayerID : " + playerId);

                deviceKey = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                NMGPlayerPrefs.SetDeviceKey(deviceKey);
                Log.Debug("[NMGPlayMode.SessionManager] Save new deviceKey : " + deviceKey);

                InitTalkKit();
            }
        }
Beispiel #2
0
 public static void DeleteAll()
 {
     NMGPlayerPrefs.SetPlayerId(null);
     NMGPlayerPrefs.SetDeviceKey(null);
     NMGPlayerPrefs.SetRegion(null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.EveryNetmarble, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.Facebook, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.Kakao, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.Google, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.GameCenter, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.Naver, null);
     NMGPlayerPrefs.SetChannelKey(NMGChannel.Twitter, null);
     NMGPlayerPrefs.SetCountryCode(null);
     NMGPlayerPrefs.SetLanguage(null);
     NMGPlayerPrefs.SetJoinedCountryCode(null);
     NMGPlayerPrefs.SetIPAddress(null);
 }
Beispiel #3
0
        public void SelectChannelConnectOption(ChannelConnectOption option, Session.SelectChannelConnectOptionDelegate handler)
        {
            ChannelConnectOptionType type = option.Type;
            NMGChannel channel            = (NMGChannel)option.ChannelCode;
            string     playerID           = option.PlayerID;
            string     channelID          = option.ChannelID;
            string     region             = option.Region;

            if (type == ChannelConnectOptionType.Cancel)
            {
                NMGPlayerPrefs.SetChannelKey(channel, null);

                Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");
                Log.Debug("[NMGPlayMode.SessionManager] SelectChannelConnectOption OK (" + result + ")");

                if (handler != null)
                {
                    handler(result);
                }
            }
            else if (type == ChannelConnectOptionType.CreateChannelConnection)
            {
                playerId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                NMGPlayerPrefs.SetPlayerId(playerId);
                Log.Debug("[NMGPlayMode.SessionManager] Save new PlayerID : " + playerId);

                deviceKey = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                NMGPlayerPrefs.SetDeviceKey(deviceKey);
                Log.Debug("[NMGPlayMode.SessionManager] Save new deviceKey : " + deviceKey);

                testData.SetChannelConnectionData(playerId, deviceKey);

                ChannelConnectionData savedData = testData.GetChannelConnectionData(playerId);
                savedData.SetChannelKeyByChannel(channel, channelID);

                NMGPlayerPrefs.SetChannelKey(NMGChannel.EveryNetmarble, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Facebook, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Kakao, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Google, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.GameCenter, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Naver, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Twitter, null);
                NMGPlayerPrefs.SetChannelKey(channel, channelID);

                NMGPlayerPrefs.SetRegion(region);

                selectChannelConnectOptionHandler = handler;
                SignIn(OnChannelOptionSignIn, null);
                UpdateTalkKit();
            }
            else if (type == ChannelConnectOptionType.LoadChannelConnection)
            {
                ChannelConnectionData savedData = testData.GetChannelConnectionData(playerID);

                NMGPlayerPrefs.SetPlayerId(playerID);
                NMGPlayerPrefs.SetDeviceKey(savedData.DeviceKey);
                NMGPlayerPrefs.SetRegion(region);

                NMGPlayerPrefs.SetChannelKey(NMGChannel.EveryNetmarble, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Facebook, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Kakao, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Google, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.GameCenter, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Naver, null);
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Twitter, null);
                NMGPlayerPrefs.SetChannelKey(channel, channelID);

                playerId = playerID;

                selectChannelConnectOptionHandler = handler;
                SignIn(OnChannelOptionSignIn, null);
                UpdateTalkKit();
            }

            /* else if (type == ChannelConnectOptionType.UpdateChannelConnection)
             * {
             *   NMPlayModeChannelConnectionData savedData = testData.GetChannelConnectionData(playerID);
             *   NMPlayModeChannelConnectionData savedChannelData = testData.GetChannelConnectionData(channel, channelID);
             *
             *   if (savedChannelData != null)
             *   {
             *       savedChannelData.SetChannelKeyByChannel(channel, null);
             *   }
             *
             *   savedData.SetChannelKeyByChannel(channel, channelID);
             *   NMPlayModePlayerPrefs.SetChannelKey(channel, channelID);
             *
             *   Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");
             *   Log.Debug("[NMGPlayMode.SessionManager] SelectChannelConnectOption OK (" + result + ")");
             *
             *   if (handler != null)
             *       handler(result);
             * }*/
        }
Beispiel #4
0
        private void ProcessData(string jsonString, SignInDelegate callback, Session.SignInDelegate handler)
        {
            JsonData jsonData = JsonMapper.ToObject(jsonString);

            int    resultCode    = (int)jsonData["resultCode"];
            string resultMessage = jsonData["resultMessage"].ToString();

            if (resultCode == 200)
            {
                JsonData    playerData = jsonData["player"];
                IDictionary playerDic  = playerData as IDictionary;

                playerId = playerDic["playerId"].ToString();

                string region = null;
                if (playerDic.Contains("gameRegion"))
                {
                    region = playerDic["gameRegion"].ToString();
                }
                NMGPlayerPrefs.SetRegion(region);
                Log.Debug("[NMGPlayMode.SessionManager] Save new region : " + region);

                string joinedCountryCode = null;

                if (playerDic.Contains("joinedCountryCode"))
                {
                    joinedCountryCode = playerDic["joinedCountryCode"].ToString();
                }
                NMGPlayerPrefs.SetJoinedCountryCode(joinedCountryCode);
                Log.Debug("[NMGPlayMode.SessionManager] Save new JoinedCountryCode : " + joinedCountryCode);

                JsonData resultData = jsonData["resultData"];
                gameToken = resultData["gameToken"].ToString();

                JsonData keyInfoData = resultData["cipherKeyList"]["keyInfos"];

                for (int i = 0; i < keyInfoData.Count; i++)
                {
                    string cipherType = keyInfoData[i]["cipherType"].ToString();
                    string secretKey  = keyInfoData[i]["secretKey"].ToString();

                    Cipher cipher = null;
                    if (cipherType == "CIPHER_RC4_40")
                    {
                        cipher = new Cipher(CipherType.RC4_40, secretKey, null);
                    }
                    else if (cipherType == "CIPHER_AES_128_CBC")
                    {
                        string aesInitVec = keyInfoData[i]["aesInitVec"].ToString();
                        cipher = new Cipher(CipherType.AES_128_CBC, secretKey, aesInitVec);
                    }

                    if (cipher != null)
                    {
                        cipherDataDic[cipher.CipherType] = cipher;
                    }
                }

                JsonData hmacInfoData = resultData["hmacInfoList"]["hmacInfos"];

                for (int i = 0; i < hmacInfoData.Count; i++)
                {
                    string hmacType = hmacInfoData[i]["hmacType"].ToString();
                    string hmacKey  = hmacInfoData[i]["hmacKey"].ToString();
                    hmacDataDic[hmacType] = hmacKey;
                }

                if (callback != null && callback is SignInDelegate)
                {
                    testData.SetChannelConnectionData(playerId, deviceKey);
                    CheckConnectedChannelAndAutoSignin(playerId);

                    // Talk
                    SignedTalkKit();

                    Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");
                    Log.Debug("[NMGPlayMode.SessionManager] SignIn OK (" + result + ")");

                    callback(result, handler);
                }
            }
            else
            {
                if (callback != null && callback is SignInDelegate)
                {
                    Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SERVICE, "ErrorCode(" + resultCode + "), ErrorMessage(" + resultMessage + ")");
                    Log.Debug("[NMGPlayMode.SessionManager] SignIn Fail (" + result + ")");
                    callback(result, handler);
                }
            }
        }