示例#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();
            }
        }
示例#2
0
        public void DisconnectFromChannel(int channelCode, Session.DisconnectFromChannelDelegate handler)
        {
            NMGPlayerPrefs.SetChannelKey((NMGChannel)channelCode, null);

            Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");

            if (handler != null)
            {
                handler(result);
            }
        }
示例#3
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);
 }
示例#4
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);
             * }*/
        }
示例#5
0
        void OnConnectToChannel(Result result, NMGChannel channel, string channelKey, Session.ConnectToChannelDelegate handler)
        {
            if (result.IsSuccess())
            {
                ChannelConnectionData savedData = testData.GetChannelConnectionData(playerId);
                string channelKeyAtPlayerID     = savedData.GetChannelKeyByChannel(channel);

                ChannelConnectionData savedChannelData = testData.GetChannelConnectionData(channel, channelKey);

                if (string.IsNullOrEmpty(channelKeyAtPlayerID))
                {
                    if (savedChannelData == null)
                    {
                        // ok 연결
                        savedData.SetChannelKeyByChannel(channel, channelKey);
                        NMGPlayerPrefs.SetChannelKey(channel, channelKey);

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

                        if (handler != null)
                        {
                            handler(channelResult, null);
                        }
                    }
                    else
                    {
                        // 다른pid에 연결 되어있음
                        if (channel == NMGChannel.Kakao)
                        {
                            SelectOptionInConnectToChannel(new ChannelConnectOption(ChannelConnectOptionType.LoadChannelConnection, savedChannelData.PlayerId, (int)channel, channelKey, savedChannelData.GameRegion), handler);
                            return;
                        }

                        List <ChannelConnectOption> channelConnectOptionList = new List <ChannelConnectOption>();
                        if (channel != NMGChannel.GameCenter)
                        {
                            channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.Cancel, savedData.PlayerId, (int)channel, null, savedData.GameRegion));
                        }
                        //channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.UpdateChannelConnection, savedData.PlayerId, channel, channelKey, savedData.GameRegion));
                        channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.LoadChannelConnection, savedChannelData.PlayerId, (int)channel, channelKey, savedChannelData.GameRegion));

                        Result channelResult = new Result(Result.NETMARBLES_DOMAIN, Result.CONNECT_CHANNEL_OPTION_USED_CHANNELID, "Please select channel connect option.");
                        Log.Debug("[NMGPlayMode.SessionManager] ConnectToChannel Fail(" + channelResult + ")");

                        if (handler != null)
                        {
                            handler(channelResult, channelConnectOptionList);
                        }
                    }
                }
                else
                {
                    if (savedChannelData == null)
                    {
                        if (channelKeyAtPlayerID.Equals(channelKey))
                        {
                            // 나올 수 없음
                        }
                        else
                        {
                            // 채널 변경하려고 함
                            if (channel == NMGChannel.Kakao)
                            {
                                SelectOptionInConnectToChannel(new ChannelConnectOption(ChannelConnectOptionType.CreateChannelConnection, null, (int)channel, channelKey, NMGPlayerPrefs.GetRegion()), handler);
                                return;
                            }

                            List <ChannelConnectOption> channelConnectOptionList = new List <ChannelConnectOption>();
                            if (channel != NMGChannel.GameCenter)
                            {
                                channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.Cancel, savedData.PlayerId, (int)channel, channelKeyAtPlayerID, savedData.GameRegion));
                            }
                            channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.CreateChannelConnection, null, (int)channel, channelKey, NMGPlayerPrefs.GetRegion()));

                            Result channelResult = new Result(Result.NETMARBLES_DOMAIN, Result.CONNECT_CHANNEL_OPTION_NEW_CHANNELID, "Please select channel connect option.");
                            Log.Debug("[NMGPlayMode.SessionManager] ConnectToChannel Fail(" + channelResult + ")");

                            if (handler != null)
                            {
                                handler(channelResult, channelConnectOptionList);
                            }
                        }
                    }
                    else
                    {
                        if (channelKeyAtPlayerID.Equals(channelKey))
                        {
                            // 같은 거 ok
                            NMGPlayerPrefs.SetChannelKey(channel, channelKey);

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

                            if (handler != null)
                            {
                                handler(channelResult, null);
                            }
                        }
                        else
                        {
                            //bothChannelIDsMappedPlayerIDs 각각 연결되어있음
                            if (channel == NMGChannel.Kakao)
                            {
                                SelectOptionInConnectToChannel(new ChannelConnectOption(ChannelConnectOptionType.LoadChannelConnection, savedChannelData.PlayerId, (int)channel, channelKey, savedChannelData.GameRegion), handler);
                                return;
                            }

                            List <ChannelConnectOption> channelConnectOptionList = new List <ChannelConnectOption>();
                            if (channel != NMGChannel.GameCenter)
                            {
                                channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.Cancel, savedData.PlayerId, (int)channel, channelKeyAtPlayerID, savedData.GameRegion));
                            }
                            channelConnectOptionList.Add(new ChannelConnectOption(ChannelConnectOptionType.LoadChannelConnection, savedChannelData.PlayerId, (int)channel, channelKey, savedChannelData.GameRegion));

                            Result channelResult = new Result(Result.NETMARBLES_DOMAIN, Result.CONNECT_CHANNEL_OPTION_USED_CHANNELID, "Please select channel connect option.");
                            Log.Debug("[NMGPlayMode.SessionManager] ConnectToChannel Fail(" + channelResult + ")");

                            if (handler != null)
                            {
                                handler(channelResult, channelConnectOptionList);
                            }
                        }
                    }
                }
            }
            else
            {
                if (handler != null)
                {
                    handler(result, null);
                }
            }
        }
示例#6
0
        private void CheckConnectedChannelAndAutoSignin(string playerId)
        {
            ChannelConnectionData savedData = testData.GetChannelConnectionData(playerId);

            if (string.IsNullOrEmpty(savedData.EmailKey))
            {
                NMGPlayerPrefs.SetChannelKey(NMGChannel.EveryNetmarble, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(NMGPlayerPrefs.GetChannelKey(NMGChannel.EveryNetmarble)))
                {
                    string emailIdKey    = savedData.EmailKey;
                    string localSavedKey = NMGPlayerPrefs.GetChannelKey(NMGChannel.EveryNetmarble);

                    if (emailIdKey.Equals(localSavedKey))
                    {
                        AutoChannelSignin(NMGChannel.EveryNetmarble, emailIdKey);
                    }
                }
            }

            if (string.IsNullOrEmpty(savedData.FacebookKey))
            {
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Facebook, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(NMGPlayerPrefs.GetChannelKey(NMGChannel.Facebook)))
                {
                    string facebookKey   = savedData.FacebookKey;
                    string localSavedKey = NMGPlayerPrefs.GetChannelKey(NMGChannel.Facebook);

                    if (facebookKey.Equals(localSavedKey))
                    {
                        AutoChannelSignin(NMGChannel.Facebook, facebookKey);
                    }
                }
            }

            if (string.IsNullOrEmpty(savedData.GoogleKey))
            {
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Google, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(NMGPlayerPrefs.GetChannelKey(NMGChannel.Google)))
                {
                    string googleKey     = savedData.GoogleKey;
                    string localSavedKey = NMGPlayerPrefs.GetChannelKey(NMGChannel.Google);

                    if (googleKey.Equals(localSavedKey))
                    {
                        AutoChannelSignin(NMGChannel.Google, googleKey);
                    }
                }
            }


            if (string.IsNullOrEmpty(savedData.NaverKey))
            {
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Naver, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(NMGPlayerPrefs.GetChannelKey(NMGChannel.Naver)))
                {
                    string naverKey      = savedData.NaverKey;
                    string localSavedKey = NMGPlayerPrefs.GetChannelKey(NMGChannel.Naver);

                    if (naverKey.Equals(localSavedKey))
                    {
                        AutoChannelSignin(NMGChannel.Naver, naverKey);
                    }
                }
            }

            if (string.IsNullOrEmpty(savedData.TwitterKey))
            {
                NMGPlayerPrefs.SetChannelKey(NMGChannel.Twitter, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(NMGPlayerPrefs.GetChannelKey(NMGChannel.Twitter)))
                {
                    string twitterKey    = savedData.TwitterKey;
                    string localSavedKey = NMGPlayerPrefs.GetChannelKey(NMGChannel.Twitter);

                    if (twitterKey.Equals(localSavedKey))
                    {
                        AutoChannelSignin(NMGChannel.Twitter, twitterKey);
                    }
                }
            }
        }