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); } } }