1013 lines
29 KiB
Plaintext
1013 lines
29 KiB
Plaintext
GVoiceProxy = class('GVoiceProxy', pm.Proxy)
|
||
GVoiceProxy.Instance = nil;
|
||
GVoiceProxy.NAME = "GVoiceProxy"
|
||
|
||
GVoiceTarget =
|
||
{
|
||
OpenMic = 1,
|
||
CloseMic = 2,
|
||
BuildTeamAndOpenMic = 2,
|
||
BuildTeamAndCloseMic = 3,
|
||
EnterGuildChannelAndCloseMic = 4,
|
||
EnterGuildChannelAndOpenMic = 5,
|
||
EnterGuildChannelAndNotAuthorized = 6,
|
||
BuildTeamAndKeepLastMicState = 7
|
||
}
|
||
|
||
function GVoiceProxy:DebugLog(msg)
|
||
-- body
|
||
if false then
|
||
Debug.Log("GVoiceProxy::::"..msg)
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:ctor(proxyName, data)
|
||
self.proxyName = proxyName or GVoiceProxy.NAME
|
||
if(GVoiceProxy.Instance == nil) then
|
||
GVoiceProxy.Instance = self
|
||
end
|
||
if data ~= nil then
|
||
self:setData(data)
|
||
end
|
||
self:Init()
|
||
self:AddEvts()
|
||
end
|
||
|
||
function GVoiceProxy:TimeTickTest()
|
||
if AppEnvConfig.IsTestApp then
|
||
-- TimeTickManager.Me():CreateTick(0, 2500, function ()
|
||
-- local test = "{\"appId\":\"1003051\",\"avgPower\":\"0.1\",\"ext1\":\"\",\"ext2\":\"\",\"msgBody\":\"\",\"msgType\":0,\"roomId\":\"7og7hjgloj8kd2hg\",\"textMsg\":\"\",\"userId\":\"4309891875\",\"voiceUrl\":\"\"}"
|
||
-- helplog("@1")
|
||
-- self:HandleReceiveTextMessageNotify(test)
|
||
-- end, self, 13);
|
||
-- TimeTickManager.Me():CreateTick(0, 1000, function ()
|
||
-- helplog("@2")
|
||
-- local test = "{\"appId\":\"1003051\",\"avgPower\":\"0.8\",\"ext1\":\"\",\"ext2\":\"\",\"msgBody\":\"\",\"msgType\":0,\"roomId\":\"7og7hjgloj8kd2hg\",\"textMsg\":\"\",\"userId\":\"4309891875\",\"voiceUrl\":\"\"}"
|
||
-- self:HandleReceiveTextMessageNotify(test)
|
||
-- end, self, 14)
|
||
end
|
||
end
|
||
|
||
VoiceEnvPowerFromOthers = 0.2
|
||
VoiceEnvPowerFromMySelf = 0.2
|
||
|
||
function GVoiceProxy:IsOpenByCeHua()
|
||
if AppEnvConfig.IsTestApp then
|
||
--self:DebugLog("***************************程式自測")
|
||
--delay延遲時間 ,interval頻率ms ,func回撥,owner回撥的所有者,id標識(可防止重複tick)
|
||
-- TimeTickManager.Me():CreateTick(0, 1000, function ()
|
||
-- -- Debug.Log("***************************************計時器測試{\"avgPower\" : 0.005546837579458952,\"peakPower\" : 0.0172119140625}")
|
||
-- local content = "{\"avgPower\" : 0.005546837579458952,\"peakPower\" : 0.0172119140625}"
|
||
-- self:HandleRecorderMeteringPeakPowerNotify(content)
|
||
-- end, self, 12);
|
||
--TimeTickManager.Me():CreateTick(0.5, 1000, function ()
|
||
--local content = ""
|
||
-- local content = "{\"avgPower\" : 1,\"peakPower\" : 1}"
|
||
--self:HandleRecorderMeteringPeakPowerNotify(content)
|
||
--end, self, 12);
|
||
return true
|
||
end
|
||
|
||
if GameConfig.OpenVoice ==nil then
|
||
return true
|
||
end
|
||
|
||
return GameConfig.OpenVoice
|
||
end
|
||
|
||
function GVoiceProxy:HandleRecorderMeteringPeakPowerNotify(msg)
|
||
self:DebugLog("========HandleRecorderMeteringPeakPowerNotify=====msg:"..msg)
|
||
end
|
||
|
||
function GVoiceProxy:HandleReceiveTextMessageNotify(msg)
|
||
self:DebugLog("$$$HandleReceiveTextMessageNotify Game.Myself.data.id:"..Game.Myself.data.id)
|
||
local decodeTable = json.decode(msg)
|
||
local data = {}
|
||
|
||
if decodeTable.userId and decodeTable.avgPower then
|
||
data.userId = decodeTable.userId
|
||
data.avgPower = tonumber(decodeTable.avgPower)
|
||
else
|
||
helplog("參數問題!")
|
||
do return end
|
||
end
|
||
|
||
if Game.Myself.data.id~= data.userId then
|
||
if data.avgPower and data.avgPower>VoiceEnvPowerFromOthers then
|
||
--顯示麥克
|
||
data.showMic = true
|
||
self:DebugLog("$$$data.showMic = true data.avgPower:"..data.avgPower.." VoiceEnvPower:"..VoiceEnvPowerFromOthers.." data.userId"..data.userId)
|
||
else
|
||
--不顯示麥克
|
||
data.showMic = false
|
||
self:DebugLog("$$$data.showMic = true data.avgPower:"..data.avgPower.." VoiceEnvPower:"..VoiceEnvPowerFromOthers.." data.userId"..data.userId)
|
||
end
|
||
|
||
if self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
self:DebugLog("$$$others:TEAM_ENUM")
|
||
EventManager.Me():PassEvent(TeamEvent.VoiceChange, data);
|
||
else
|
||
self:DebugLog("$$$others:Guild")
|
||
EventManager.Me():PassEvent(GuildEvent.VoiceChange, data);
|
||
end
|
||
else
|
||
self:DebugLog("$$$myself:")
|
||
if data.avgPower and data.avgPower>VoiceEnvPowerFromMySelf then
|
||
--顯示麥克
|
||
data.showMic = true
|
||
self:DebugLog("$$$data.showMic = true data.avgPower:"..data.avgPower.." VoiceEnvPower:"..VoiceEnvPowerFromMySelf.." data.userId"..data.userId)
|
||
else
|
||
--不顯示麥克
|
||
data.showMic = false
|
||
self:DebugLog("$$$data.showMic = true data.avgPower:"..data.avgPower.." VoiceEnvPower:"..VoiceEnvPowerFromMySelf.." data.userId"..data.userId)
|
||
end
|
||
EventManager.Me():PassEvent(MyselfEvent.VoiceChange, data);
|
||
end
|
||
end
|
||
|
||
|
||
function GVoiceProxy:Init()
|
||
if self:IsOpenByCeHua() == false then
|
||
do return end
|
||
end
|
||
|
||
if ApplicationInfo.IsRunOnEditor() then
|
||
do return end
|
||
end
|
||
|
||
ROVoice.ChatSDKInit(0,"1003051",1,function (msg)
|
||
self:DebugLog("ROVoice.ChatSDKInit msg:"..msg)
|
||
self.hasInit = true
|
||
end)
|
||
|
||
ROVoice.ReceiveTextMessageNotify
|
||
(
|
||
function (msg)
|
||
|
||
self:HandleReceiveTextMessageNotify(msg)
|
||
end,
|
||
function (msg)
|
||
end,
|
||
function (msg)
|
||
|
||
end
|
||
)
|
||
|
||
ROVoice.LoginNotify
|
||
(
|
||
function (msg)
|
||
-- body
|
||
self:DebugLog("@@@ROVoice.LoginNotify msg:"..msg)
|
||
end)
|
||
|
||
ROVoice.LogoutNotify
|
||
(
|
||
function (msg)
|
||
-- body
|
||
self:DebugLog("@@@ROVoice.LogoutNotify msg:"..msg)
|
||
end
|
||
)
|
||
|
||
ROVoice._SendRealTimeVoiceMessageErrorNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_SendRealTimeVoiceMessageErrorNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._ReceiveRealTimeVoiceMessageNofify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_ReceiveRealTimeVoiceMessageNofify:"..msg)
|
||
end
|
||
|
||
ROVoice._ReceiveTextMessageNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_ReceiveTextMessageNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._RecorderMeteringPeakPowerNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@ROVoice._RecorderMeteringPeakPowerNotify = function (msg)"..msg)
|
||
end
|
||
|
||
ROVoice._PlayMeteringPeakPowerNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_PlayMeteringPeakPowerNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._AudioToolsRecorderMeteringPeakPowerNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_AudioToolsRecorderMeteringPeakPowerNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._AudioToolsPlayMeteringPeakPowerNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_AudioToolsPlayMeteringPeakPowerNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._MicStateNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_MicStateNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._onConnectFail = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_onConnectFail:"..msg)
|
||
end
|
||
|
||
ROVoice._onReconnectSuccess = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_onReconnectSuccess:"..msg)
|
||
end
|
||
|
||
ROVoice._LoginNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_LoginNotify:"..msg)
|
||
end
|
||
|
||
ROVoice._LogoutNotify = function (msg)
|
||
-- body
|
||
self:DebugLog("@@@_LogoutNotify:"..msg)
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:AddEvts()
|
||
|
||
end
|
||
|
||
function GVoiceProxy:ChangeTeamVoiceState(teamVoiceState)
|
||
self:ChangeVoiceState(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index,teamVoiceState)
|
||
end
|
||
|
||
function GVoiceProxy:ChangeVoiceState(voiceType,teamVoiceState)
|
||
|
||
end
|
||
|
||
function GVoiceProxy:ChangeGuildVoiceState(guildVoiceState)
|
||
self:ChangeVoiceState(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index ,guildVoiceState)
|
||
end
|
||
|
||
function GVoiceProxy:RecvEnterTeam(data)
|
||
|
||
if TeamProxy.Instance:IHaveTeam() and self.curTarget == GVoiceTarget.BuildTeamAndOpenMic then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
elseif TeamProxy.Instance:IHaveTeam() and self.curTarget == GVoiceTarget.BuildTeamAndCloseMic then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:Reset()
|
||
self.curTarget = nil
|
||
TimeTickManager.Me():ClearTick(self, 3)
|
||
|
||
end
|
||
|
||
function GVoiceProxy:RecvExitTeam(data)
|
||
if self:IsOpenByCeHua() == false then
|
||
do return end
|
||
end
|
||
|
||
if ApplicationInfo.IsRunOnEditor() then
|
||
MsgManager.FloatMsg(nil, "目前為編輯器 無法使用語音功能")
|
||
self.curChannel = nil
|
||
self.roomid=nil
|
||
do return end
|
||
end
|
||
|
||
if self.curChannel ==nil then
|
||
self:DebugLog("目前不在任何語音訊道中 不用處理")
|
||
do return end
|
||
elseif self.curChannel ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
MsgManager.ShowMsgByID(25489)
|
||
ROVoice.Logout( function (msg)
|
||
-- body
|
||
self:DebugLog("ROVoice.Logout1 msg:"..msg)
|
||
self.curChannel = nil
|
||
self.roomid=nil
|
||
end)
|
||
|
||
elseif self.curChannel ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index then
|
||
MsgManager.ShowMsgByID(25493)
|
||
ROVoice.Logout( function (msg)
|
||
-- body
|
||
self:DebugLog("ROVoice.Logout2 msg:"..msg)
|
||
self.curChannel = nil
|
||
self.roomid=nil
|
||
end)
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:LeaveGVoiceRoomAtChannel(targetChannel)
|
||
if self:IsOpenByCeHua() == false then
|
||
do return end
|
||
end
|
||
if self.curChannel ==nil then
|
||
elseif self.curChannel ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index and targetChannel == self.curChannel then
|
||
--MsgManager.FloatMsg(nil, "離開隊伍語音")
|
||
MsgManager.ShowMsgByID(25489)
|
||
|
||
elseif self.curChannel ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index and targetChannel == self.curChannel then
|
||
--MsgManager.FloatMsg(nil, "離開公會語音")
|
||
MsgManager.ShowMsgByID(25493)
|
||
end
|
||
|
||
if self.roomid~=nil then
|
||
self.roomid=nil
|
||
end
|
||
self.curChannel = nil
|
||
end
|
||
|
||
function GVoiceProxy:GetCurChannel()
|
||
return self.curChannel or nil
|
||
end
|
||
|
||
function GVoiceProxy:RecvQueryRealtimeVoiceIDCmd(data)
|
||
self:DebugLog("!!!!!!!!!!!!!!GVoiceProxy--> RecvQueryRealtimeVoiceIDCmd data.channel"..data.channel)
|
||
if self:IsOpenByCeHua() == false then
|
||
do return end
|
||
end
|
||
|
||
if self.hasInit == false then
|
||
self:DebugLog("!!!!!!!!!!!!!!沒有初始化")
|
||
do return end
|
||
end
|
||
|
||
if self.curChannel == data.channel then
|
||
self:DebugLog("已在同類型的房間裡面")
|
||
do return end
|
||
end
|
||
|
||
if self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
EventManager.Me():PassEvent(TeamEvent.VoiceChange, nil);
|
||
elseif self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index then
|
||
EventManager.Me():PassEvent(GuildEvent.VoiceChange, nil);
|
||
end
|
||
|
||
self.curChannel = data.channel
|
||
self.roomid = data.id
|
||
|
||
self:DebugLog("+++++Game.Myself.data.id:"..Game.Myself.data.id.."++++++++self.roomid:"..self.roomid)
|
||
|
||
FunctionBGMCmd.Me():SettingSetVolume(0)
|
||
AudioUtility.SetVolume(0)
|
||
EventManager.Me():PassEvent(MyselfEvent.EnterVoiceChannel, nil);
|
||
|
||
if self.curTarget == GVoiceTarget.BuildTeamAndCloseMic then
|
||
self:DebugLog("----1")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyClosed)
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
ROVoice.ChatMic(false,function (msg)
|
||
self:DebugLog("++++1")
|
||
end)
|
||
end)
|
||
end
|
||
elseif self.curTarget == GVoiceTarget.BuildTeamAndOpenMic then
|
||
self:DebugLog("----2")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyOpened)
|
||
self:DebugLog("----21")
|
||
if self.hasInit then
|
||
self:DebugLog("----22")
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
|
||
self:DebugLog("----23")
|
||
ROVoice.ChatMic(true,function (msg)
|
||
self:DebugLog("++++2")
|
||
end)
|
||
end)
|
||
end
|
||
elseif self.curTarget == GVoiceTarget.EnterGuildChannelAndOpenMic then
|
||
self:DebugLog("----3")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Guild_MicPhoneHasAlreadyOpened)
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
ROVoice.ChatMic(true,function (msg)
|
||
self:DebugLog("++++3")
|
||
end)
|
||
end)
|
||
end
|
||
elseif self.curTarget == GVoiceTarget.EnterGuildChannelAndCloseMic then
|
||
self:DebugLog("----4")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Guild_MicPhoneHasAlreadyClosed)
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
ROVoice.ChatMic(false,function (msg)
|
||
self:DebugLog("++++4")
|
||
end)
|
||
end)
|
||
end
|
||
elseif self.curTarget == GVoiceTarget.EnterGuildChannelAndNotAuthorized then
|
||
self:DebugLog("----5")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Guild_MicPhoneHasAlreadyClosed)
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouAreNotGuildAuthorized)
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
ROVoice.ChatMic(false,function (msg)
|
||
self:DebugLog("++++5")
|
||
end)
|
||
end)
|
||
end
|
||
elseif self.curTarget == GVoiceTarget.BuildTeamAndKeepLastMicState then
|
||
self:DebugLog("----6")
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
if self.LastMicState_IsMicOpen then
|
||
ROVoice.ChatMic(true,function (msg)
|
||
self:DebugLog("++++6")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyOpened)
|
||
end)
|
||
else
|
||
ROVoice.ChatMic(false,function (msg)
|
||
self:DebugLog("++++7")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyClosed)
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
else
|
||
self:DebugLog("----7")
|
||
if self.hasInit then
|
||
ROVoice.ChatSDKLogin( Game.Myself.data.id, self.roomid,function (msg)
|
||
if self.LastMicState_IsMicOpen then
|
||
ROVoice.ChatMic(true,function (msg)
|
||
self:DebugLog("++++8")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyOpened)
|
||
end)
|
||
else
|
||
ROVoice.ChatMic(false,function (msg)
|
||
self:DebugLog("++++9")
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.Team_MicPhoneHasAlreadyClosed)
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
|
||
self.curTarget = nil
|
||
end
|
||
|
||
function GVoiceProxy:GetPlayerChooseToJoinGuildVoice()
|
||
return self.ChooseToJoinGuildVoice or false
|
||
end
|
||
|
||
function GVoiceProxy:SetPlayerChooseToJoinGuildVoice(b)
|
||
self.ChooseToJoinGuildVoice = b
|
||
end
|
||
|
||
function GVoiceProxy:ActiveEnterChannel(channel)
|
||
if ExternalInterfaces.DoIHaveRecordPermission~=nil and ExternalInterfaces.DoIHaveRecordPermission()==false then
|
||
MsgManager.ConfirmMsgByID(25859,
|
||
function ()
|
||
|
||
end,
|
||
function ()
|
||
|
||
end,nil)
|
||
else
|
||
if ExternalInterfaces.DoIHaveRecordPermission==nil then
|
||
self:DebugLog("ExternalInterfaces.DoIHaveRecordPermission==nil")
|
||
end
|
||
end
|
||
|
||
|
||
if self.curChannel == channel then
|
||
self:DebugLog("已在同類型的房間里")
|
||
do return end
|
||
end
|
||
self:DebugLog("===============function GVoiceProxy:ActiveEnterChannel(channel)=========== channel:"..channel)
|
||
|
||
ServiceChatCmdProxy.Instance:CallQueryRealtimeVoiceIDCmd(channel, nil)
|
||
end
|
||
|
||
function GVoiceProxy:UseGVoiceInReal(channelIndex,roomid)
|
||
if not self:HaveInitSuccess() then
|
||
MsgManager.FloatMsg(nil, "錯誤程式碼:013")
|
||
do return end
|
||
end
|
||
|
||
if channelIndex ==nil then
|
||
MsgManager.FloatMsg(nil, "錯誤程式碼:012")
|
||
elseif channelIndex ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
|
||
elseif channelIndex ==ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index then
|
||
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:ConfirmMicState()
|
||
if not self:IsMaiOpen() then
|
||
self:DebugLog("關閉mic")
|
||
return
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:ConfirmYangState()
|
||
if not self:IsYangOpen() then
|
||
self:DebugLog("關閉揚聲器")
|
||
return
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:HaveInitSuccess()
|
||
if not self.haveInitSuccess then
|
||
MsgManager.FloatMsg(nil, "錯誤程式碼:014")
|
||
return false
|
||
else
|
||
return true
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:RecvBanRealtimeVoiceGuildCmd(data)
|
||
self:DebugLog("GVoiceProxy--> RecvBanRealtimeVoiceGuildCmd")
|
||
end
|
||
|
||
function GVoiceProxy:RecvOpenRealtimeVoiceGuildCmd(data)
|
||
helplog("GVoiceProxy--> RecvOpenRealtimeVoiceGuildCmd")
|
||
|
||
end
|
||
|
||
function GVoiceProxy:RecvOpenRealtimeVoiceTeamCmd(data)
|
||
helplog("GVoiceProxy--> RecvOpenRealtimeVoiceTeamCmd")
|
||
|
||
end
|
||
|
||
function GVoiceProxy:RecvGuildMemberDataUpdateGuildCmd(data)
|
||
self:DebugLog("GVoiceProxy--> RecvGuildMemberDataUpdateGuildCmd")
|
||
|
||
for i=1,#data.updates do
|
||
local updateData = data.updates[i];
|
||
if updateData.type == 27 and data.charid == Game.Myself.data.id then
|
||
if updateData.value == 0 then
|
||
self:DebugLog("我被禁言1")
|
||
if self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index and self.roomid~=nil then
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(false,function (msg)
|
||
|
||
end)
|
||
end
|
||
end
|
||
elseif updateData.value == 1 then
|
||
self:DebugLog("我沒被禁言1")
|
||
|
||
end
|
||
end
|
||
end
|
||
|
||
-- charid: 4294967366
|
||
-- updates {
|
||
-- value: 0
|
||
-- data:
|
||
-- type: 27
|
||
-- }
|
||
-- type: 1
|
||
end
|
||
|
||
function GVoiceProxy:RecvMemberDataUpdate(data)
|
||
self:DebugLog("function GVoiceProxy:RecvGuildMemberDataUpdateGuildCmd(data)")
|
||
if TeamProxy.Instance.myTeam~=nil then
|
||
local myMembers = TeamProxy.Instance.myTeam:GetMembersList();
|
||
for i=1,#myMembers do
|
||
local memberData = myMembers[i];
|
||
if memberData.id == data.id and data.id == Game.Myself.data.id then
|
||
if memberData:GetRealTimeVoice() == 0 then
|
||
self:DebugLog("被禁言3")
|
||
|
||
if self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index and self.roomid~=nil then
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(false,function (msg)
|
||
|
||
end)
|
||
end
|
||
end
|
||
|
||
elseif memberData:GetRealTimeVoice() == 1 then
|
||
self:DebugLog("沒被禁言3")
|
||
|
||
end
|
||
else
|
||
|
||
end
|
||
local note = {}
|
||
note.userId = userId
|
||
if memberData:GetRealTimeVoice() == 0 then
|
||
note.ban = true
|
||
else
|
||
note.ban = false
|
||
end
|
||
EventManager.Me():PassEvent(MyselfEvent.EnterVoiceChannel, note);
|
||
end
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:IsMySelfGongHuiJinYan()
|
||
if not GuildProxy.Instance:IHaveGuild() then
|
||
self:DebugLog("沒加入工會")
|
||
return false
|
||
end
|
||
local data = GuildProxy.Instance:GetMyGuildMemberData()
|
||
if data then
|
||
if data:IsRealtimevoice()==false then
|
||
self:DebugLog("已被禁言2")
|
||
return true
|
||
elseif data:IsRealtimevoice()==true then
|
||
self:DebugLog("沒被禁言2")
|
||
return false
|
||
else
|
||
self:DebugLog("沒查到2")
|
||
end
|
||
else
|
||
self:DebugLog("沒讀到工會數據")
|
||
return false
|
||
end
|
||
return false
|
||
end
|
||
|
||
function GVoiceProxy:IsMySelfTeamJinYan()
|
||
if TeamProxy.Instance.myTeam~=nil then
|
||
local myMembers = TeamProxy.Instance.myTeam:GetMembersList();
|
||
for i=1,#myMembers do
|
||
local memberData = myMembers[i];
|
||
if memberData.id == Game.Myself.data.id then
|
||
if memberData:GetRealTimeVoice() == 0 then
|
||
self:DebugLog("已被禁言4")
|
||
return true
|
||
elseif memberData:GetRealTimeVoice() == 1 then
|
||
self:DebugLog("沒被禁言4")
|
||
return false
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
self:DebugLog("沒隊伍")
|
||
return false
|
||
end
|
||
|
||
function GVoiceProxy:IsTeamVoiceOpen()
|
||
return self:IsThisFuncOpen(0)
|
||
end
|
||
|
||
function GVoiceProxy:GetBitByInt(num, index)
|
||
return ((num >> index) & 1) == 0
|
||
end
|
||
|
||
|
||
|
||
|
||
function GVoiceProxy:IsYangOpen()
|
||
return self:IsThisFuncOpen(2)
|
||
end
|
||
|
||
function GVoiceProxy:IsMaiOpen()
|
||
return self:IsThisFuncOpen(3)
|
||
end
|
||
|
||
function GVoiceProxy:IsThisFuncOpen(funcId)
|
||
--TODO:沒判空 感覺很慌
|
||
local setting = FunctionPerformanceSetting.Me()
|
||
local gvoice = setting:GetSetting().gvoice
|
||
local value = self:GetBitByInt(gvoice, funcId)
|
||
return value
|
||
end
|
||
--玩家給予語音授權后全為勾
|
||
function GVoiceProxy:SetAllSetViewToGou()
|
||
local gvoice = 0
|
||
for i=0,#self.gvoiceToggle do
|
||
gvoice = self:GetIntByBit(gvoice, i, not true)
|
||
end
|
||
|
||
local setting = FunctionPerformanceSetting.Me()
|
||
setting:SetGVoice(gvoice)
|
||
end
|
||
|
||
function GVoiceProxy:GetIntByBit(num, index, b)
|
||
if b then
|
||
num = num + (1<<index)
|
||
end
|
||
return num
|
||
end
|
||
|
||
function GVoiceProxy:RecvEnterGuildGuildCmd(data)
|
||
-- body
|
||
end
|
||
|
||
function GVoiceProxy:IsThisCharIdRealtimeVoiceAvailable( charid)
|
||
if self:IsOpenByCeHua() == false then
|
||
return false
|
||
end
|
||
|
||
local myGuildData = GuildProxy.Instance.myGuildData
|
||
if myGuildData==nil then
|
||
return false
|
||
end
|
||
|
||
local guildMemberData = myGuildData:GetMemberByGuid(charid);
|
||
if guildMemberData==nil then
|
||
return false
|
||
end
|
||
|
||
if guildMemberData:IsRealtimevoice() then
|
||
return true
|
||
else
|
||
return false
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:SetCurGuildRealTimeVoiceCount(count)
|
||
if count > GameConfig.Guild.realtime_voice_limit then
|
||
self.curGuildRealTimeVoiceCount = 9
|
||
else
|
||
self.curGuildRealTimeVoiceCount = count
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:GetCurGuildRealTimeVoiceCount()
|
||
local curGuildRealTimeVoiceCount = 0
|
||
local myGuildData = GuildProxy.Instance.myGuildData
|
||
if myGuildData then
|
||
local memberList = GuildProxy.Instance.myGuildData:GetMemberList();
|
||
for i=1,#memberList do
|
||
if memberList[i]:IsRealtimevoice() == true then
|
||
curGuildRealTimeVoiceCount = curGuildRealTimeVoiceCount+1
|
||
else
|
||
|
||
|
||
end
|
||
end
|
||
end
|
||
return curGuildRealTimeVoiceCount
|
||
end
|
||
|
||
--finish
|
||
function GVoiceProxy:CloseMicEnterChannel()
|
||
self.LastMicState_IsMicOpen = false
|
||
--沒頻道
|
||
if self.curChannel == nil then
|
||
--使用者選擇加入頻道
|
||
MsgManager.ConfirmMsgByID(25850,
|
||
function ()
|
||
--使用者選擇工會
|
||
if GuildProxy.Instance:IHaveGuild() then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndCloseMic
|
||
|
||
if self:IsMySelfGongHuiJinYan() then
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouAreNotGuildAuthorized)
|
||
end
|
||
else
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouDontHaveGuild)
|
||
end
|
||
end,
|
||
function ()
|
||
--使用者選擇隊伍
|
||
if TeamProxy.Instance:IHaveTeam() then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
self.curTarget = GVoiceTarget.BuildTeamAndCloseMic
|
||
else
|
||
MsgManager.ConfirmMsgByID( 25851,
|
||
function ()
|
||
if(not TeamProxy.Instance:IHaveTeam())then
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamFindPopUp});
|
||
else
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamMemberListPopUp})
|
||
end
|
||
|
||
self.curTarget = GVoiceTarget.BuildTeamAndCloseMic
|
||
end,
|
||
function ()
|
||
self.curTarget =nil
|
||
end,nil)
|
||
end
|
||
end,nil)
|
||
else
|
||
--有一瓶倒
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.MicPhoneHasAlreadyClosed)
|
||
self.LastMicState_IsMicOpen = false
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(false,function (msg)
|
||
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:OpenMicEnterChannel()
|
||
self.LastMicState_IsMicOpen = true
|
||
if self.curChannel == nil then
|
||
--使用者選擇加入頻道
|
||
MsgManager.ConfirmMsgByID( 25850,
|
||
function ()
|
||
--使用者選擇工會
|
||
if GuildProxy.Instance:IHaveGuild() then
|
||
if self:IsMySelfGongHuiJinYan() then
|
||
--無許可權 靜音進入
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndNotAuthorized
|
||
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouAreNotGuildAuthorized)
|
||
else
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndOpenMic
|
||
end
|
||
else
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouDontHaveGuild)
|
||
end
|
||
end,
|
||
function ()
|
||
--使用者選擇隊伍
|
||
if TeamProxy.Instance:IHaveTeam() then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
self.curTarget = GVoiceTarget.BuildTeamAndOpenMic
|
||
if self:IsMySelfTeamJinYan() == true then
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouAreNotAuthorizedByTeam)
|
||
end
|
||
else
|
||
MsgManager.ConfirmMsgByID( 25851,
|
||
function ()
|
||
if(not TeamProxy.Instance:IHaveTeam())then
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamFindPopUp});
|
||
else
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamMemberListPopUp})
|
||
end
|
||
self.curTarget = GVoiceTarget.BuildTeamAndOpenMic
|
||
end,
|
||
function ()
|
||
|
||
end,nil)
|
||
end
|
||
end,nil)
|
||
else
|
||
if self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.MicPhoneHasAlreadyOpened)
|
||
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(true,function (msg)
|
||
|
||
end)
|
||
end
|
||
elseif self.curChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index then
|
||
if self:IsMySelfGongHuiJinYan() then
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouAreNotAuthorized)
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(false,function (msg)
|
||
|
||
end)
|
||
end
|
||
else
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.MicPhoneHasAlreadyOpened)
|
||
if self.hasInit then
|
||
ROVoice.ChatMic(true,function (msg)
|
||
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:SwitchChannel(toChannel)
|
||
|
||
if self.curChannel == nil then
|
||
self:DebugLog("GVoiceProxy:SwitchChannel(toChannel) toChannel: nil")
|
||
--沒頻道
|
||
MsgManager.ConfirmMsgByID( 25850,
|
||
function ()
|
||
if GuildProxy.Instance:IHaveGuild() then
|
||
if self.LastMicState_IsMicOpen then
|
||
if self:IsMySelfGongHuiJinYan()==false then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndOpenMic
|
||
else
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndNotAuthorized
|
||
end
|
||
else
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndCloseMic
|
||
end
|
||
else
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouDontHaveGuild)
|
||
end
|
||
end,
|
||
function ()
|
||
--隊伍
|
||
if TeamProxy.Instance:IHaveTeam() then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
self.curTarget = GVoiceTarget.BuildTeamAndKeepLastMicState
|
||
else
|
||
MsgManager.ConfirmMsgByID( 25851,
|
||
function ()
|
||
if(not TeamProxy.Instance:IHaveTeam())then
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamFindPopUp});
|
||
else
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamMemberListPopUp})
|
||
end
|
||
self.curTarget = GVoiceTarget.BuildTeamAndKeepLastMicState
|
||
end,
|
||
function ()
|
||
|
||
end,nil)
|
||
end
|
||
end,nil)
|
||
else
|
||
self:DebugLog("@@@@GVoiceProxy:SwitchChannel(toChannel) toChannel:"..toChannel)
|
||
self.toChannel = toChannel
|
||
|
||
self:DebugLog("@@@@GVoiceProxy:SwitchChannel1")
|
||
if self.hasInit then
|
||
ROVoice.Logout( function (msg)
|
||
end)
|
||
end
|
||
|
||
self:DebugLog("@@@@GVoiceProxy:SwitchChannel2")
|
||
|
||
local sysData = Table_Sysmsg[25861]
|
||
if sysData then
|
||
MsgManager.WarnPopupParam(sysData.Title,sysData.Text,{confirmHandler = function ()
|
||
self:DebugLog("GVoice1")
|
||
self.curChannel = nil
|
||
self.roomid=nil
|
||
self:DebugLog("GVoice3")
|
||
FunctionPerformanceSetting.Me():Load()
|
||
self:DebugLog("GVoice4")
|
||
EventManager.Me():PassEvent(MyselfEvent.EnterVoiceChannel, nil);
|
||
EventManager.Me():PassEvent(TeamEvent.VoiceChange, nil);
|
||
EventManager.Me():PassEvent(GuildEvent.VoiceChange, nil);
|
||
self:DebugLog("GVoice5")
|
||
self:DebugLog("GVoiceProxy:SwitchChannel2")
|
||
if self.toChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index then
|
||
self:DebugLog("GVoiceProxy:SwitchChannel3")
|
||
if TeamProxy.Instance:IHaveTeam() then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_TEAM_ENUM.index)
|
||
self.curTarget = GVoiceTarget.BuildTeamAndKeepLastMicState
|
||
|
||
self:DebugLog("GVoiceProxy:SwitchChannel4")
|
||
else
|
||
MsgManager.ConfirmMsgByID( 25851,
|
||
function ()
|
||
if(not TeamProxy.Instance:IHaveTeam())then
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamFindPopUp});
|
||
else
|
||
self:sendNotification(UIEvent.JumpPanel, {view = PanelConfig.TeamMemberListPopUp})
|
||
end
|
||
self.curTarget = GVoiceTarget.BuildTeamAndKeepLastMicState
|
||
end,
|
||
function ()
|
||
|
||
end,nil)
|
||
end
|
||
elseif self.toChannel == ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index then
|
||
self:DebugLog("GVoiceProxy:SwitchChannel11")
|
||
if GuildProxy.Instance:IHaveGuild() then
|
||
|
||
self:DebugLog("GVoiceProxy:SwitchChannel22")
|
||
if self.LastMicState_IsMicOpen then
|
||
if self:IsMySelfGongHuiJinYan()==false then
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndOpenMic
|
||
else
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndNotAuthorized
|
||
end
|
||
else
|
||
self:ActiveEnterChannel(ChatCmd_pb.EGAMECHATCHANNEL_ECHAT_CHANNEL_GUILD_ENUM.index)
|
||
self.curTarget = GVoiceTarget.EnterGuildChannelAndCloseMic
|
||
end
|
||
else
|
||
MsgManager.FloatMsg(nil, ZhString.VoiceString.YouDontHaveGuild)
|
||
end
|
||
else
|
||
self:DebugLog("GVoiceProxy:SwitchChannel33")
|
||
end
|
||
|
||
self.toChannel = nil
|
||
|
||
|
||
end}, nil, sysData)
|
||
end
|
||
|
||
end
|
||
end
|
||
|
||
function GVoiceProxy:QuitVoice( logoutCallBack)
|
||
self.curChannel = nil
|
||
self.roomid=nil
|
||
FunctionPerformanceSetting.Me():Load()
|
||
EventManager.Me():PassEvent(MyselfEvent.EnterVoiceChannel, nil);
|
||
EventManager.Me():PassEvent(TeamEvent.VoiceChange, nil);
|
||
EventManager.Me():PassEvent(GuildEvent.VoiceChange, nil);
|
||
|
||
self:DebugLog("function GVoiceProxy:QuitVoice( logoutCallBack)")
|
||
if self.hasInit then
|
||
ROVoice.Logout( function (msg)
|
||
self:DebugLog("QuitVoice:"..msg)
|
||
if logoutCallBack~=nil then
|
||
logoutCallBack()
|
||
end
|
||
end)
|
||
else
|
||
self:DebugLog("if self.hasInit then not not")
|
||
end
|
||
end
|
||
|
||
return GVoiceProxy
|
||
|