Exemplo n.º 1
0
        public void SetChannelKeyByChannel(NMGChannel channel, string channelKey)
        {
            switch (channel)
            {
            case NMGChannel.EveryNetmarble:
                emailKey = channelKey;
                break;

            case NMGChannel.Facebook:
                facebookKey = channelKey;
                break;

            case NMGChannel.Kakao:
                kakaoTalkKey = channelKey;
                break;

            case NMGChannel.Google:
                googleKey = channelKey;
                break;

            case NMGChannel.GameCenter:
                gameCenterKey = channelKey;
                break;

            case NMGChannel.Naver:
                naverKey = channelKey;
                break;

            case NMGChannel.Twitter:
                twitterKey = channelKey;
                break;
            }
        }
Exemplo n.º 2
0
        public string GetChannelKeyByChannel(NMGChannel channel)
        {
            switch (channel)
            {
            case NMGChannel.EveryNetmarble:
                return(emailKey);

            case NMGChannel.Facebook:
                return(facebookKey);

            case NMGChannel.Kakao:
                return(kakaoTalkKey);

            case NMGChannel.Google:
                return(googleKey);

            case NMGChannel.GameCenter:
                return(gameCenterKey);

            case NMGChannel.Naver:
                return(naverKey);

            case NMGChannel.Twitter:
                return(twitterKey);

            default:
                return(null);
            }
        }
Exemplo n.º 3
0
 private void AutoChannelSignin(NMGChannel channel, string channelKey)
 {
     if (!string.IsNullOrEmpty(channelKey))
     {
         if (channelSignInHandler != null)
         {
             Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");
             channelSignInHandler(result, (int)channel);
         }
     }
 }
        public static void Show(NMGChannel channel, List <TestUserData> userList, SessionManager.ConnectToChannelDelegate callback, Session.ConnectToChannelDelegate handler)
        {
            Close();
            loginPanel = (GameObject)Instantiate(Resources.Load("NMGPlayModeChannelLoginPanel"));
            //loginPanel = (GameObject)Instantiate(EditorGUIUtility.Load("NMPlayModeChannelLoginPanel.prefab"));

            ChannelLoginController controller = loginPanel.transform.FindChild("LoginPanel").gameObject.GetComponent <ChannelLoginController>();

            controller.callback = callback;
            controller.userList = userList;
            controller.channel  = channel;
            controller.handler  = handler;
            controller.SetChannel();
        }
Exemplo n.º 5
0
        public void Add(List <TestUserData> testUserList, NMGChannel channel, string newId)
        {
            TestUserData userData = null;

            if (channel == NMGChannel.EveryNetmarble)
            {
                userData            = new EveryNetmarbleUserData(newId);
                userData.ChannelKey = ((EveryNetmarbleUserData)userData).GenerateKey();
            }
            else if (channel == NMGChannel.Facebook)
            {
                userData            = new FacebookUserData(newId);
                userData.ChannelKey = ((FacebookUserData)userData).GenerateKey();
            }
            else if (channel == NMGChannel.Kakao)
            {
                userData            = new KakaoUserData(newId);
                userData.ChannelKey = ((KakaoUserData)userData).GenerateKey();
            }
            else if (channel == NMGChannel.Google)
            {
                userData            = new GoogleUserData(newId);
                userData.ChannelKey = ((GoogleUserData)userData).GenerateKey();
            }
            else if (channel == NMGChannel.GameCenter)
            {
                userData            = new GameCenterUserData(newId);
                userData.ChannelKey = ((GameCenterUserData)userData).GenerateKey();
            }

            else if (channel == NMGChannel.Naver)
            {
                userData            = new NaverUserData(newId);
                userData.ChannelKey = ((NaverUserData)userData).GenerateKey();
            }

            else if (channel == NMGChannel.Twitter)
            {
                userData            = new TwitterUserData(newId);
                userData.ChannelKey = ((TwitterUserData)userData).GenerateKey();
            }


            Add(testUserList, userData);
        }
Exemplo n.º 6
0
        public static string GetChannelKey(NMGChannel channel)
        {
            string channelKey = null;

            switch (channel)
            {
            case NMGChannel.EveryNetmarble:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_EVERYNETMARBLE, null);
                break;

            case NMGChannel.Facebook:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_FACEBOOK, null);
                break;

            case NMGChannel.Kakao:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_KAKAO, null);
                break;

            case NMGChannel.Google:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_GOOGLEPLUS, null);
                break;

            case NMGChannel.GameCenter:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_GAMECENTER, null);
                break;

            case NMGChannel.Naver:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_NAVER, null);
                break;

            case NMGChannel.Twitter:
                channelKey = PlayerPrefs.GetString(NMGConstants.KEY_CHANNEL_ID_TWITTER, null);
                break;
            }

            if (string.IsNullOrEmpty(channelKey))
            {
                return(null);
            }

            return(channelKey);
        }
Exemplo n.º 7
0
        public static void SetChannelKey(NMGChannel channel, string channelKey)
        {
            switch (channel)
            {
            case NMGChannel.EveryNetmarble:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_EVERYNETMARBLE);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_EVERYNETMARBLE, channelKey);
                }
                break;

            case NMGChannel.Facebook:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_FACEBOOK);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_FACEBOOK, channelKey);
                }
                break;

            case NMGChannel.Kakao:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_KAKAO);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_KAKAO, channelKey);
                }
                break;

            case NMGChannel.Google:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_GOOGLEPLUS);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_GOOGLEPLUS, channelKey);
                }
                break;

            case NMGChannel.GameCenter:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_GAMECENTER);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_GAMECENTER, channelKey);
                }
                break;

            case NMGChannel.Naver:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_NAVER);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_NAVER, channelKey);
                }
                break;

            case NMGChannel.Twitter:
                if (string.IsNullOrEmpty(channelKey))
                {
                    PlayerPrefs.DeleteKey(NMGConstants.KEY_CHANNEL_ID_TWITTER);
                }
                else
                {
                    PlayerPrefs.SetString(NMGConstants.KEY_CHANNEL_ID_TWITTER, channelKey);
                }
                break;
            }
        }
Exemplo n.º 8
0
        public ChannelConnectionData GetChannelConnectionData(NMGChannel channel, string channelKey)
        {
            switch (channel)
            {
            case NMGChannel.EveryNetmarble:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.EmailKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.Facebook:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.FacebookKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.Kakao:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.KakaoTalkKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.Google:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.GoogleKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.GameCenter:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.GameCenterKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.Naver:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.NaverKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;

            case NMGChannel.Twitter:
                foreach (ChannelConnectionData channelConnectionData in channelConnectionDataList)
                {
                    if (channelKey.Equals(channelConnectionData.TwitterKey))
                    {
                        return(channelConnectionData);
                    }
                }
                break;
            }
            return(null);
        }
Exemplo n.º 9
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);
             * }*/
        }
Exemplo n.º 10
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);
                }
            }
        }