ZPlayer = ZPlayer or {}

ZPlayer._data = {}

function ZPlayer.UpdateUserMeetingInfo(res)
    local tData = res.data
    ZPlayer._data.userId    = tData.userId
    ZPlayer._data.sex       = tData.sex
    ZPlayer._data.roleType  = tData.roleType
    ZPlayer._data.nickName  = tData.nickName
    ZPlayer._data.hairstyle = tData.hairstyle
end

function ZPlayer.SetMeetingUserInfo(res)
    local tData = res.data

    ZPlayer._data.telephone = tData.telephone
end

function ZPlayer.GetRoleType()
    local roleType = ZPlayer._data.roleType

    if roleType == ROLE_TYPE.ADMIN then
        return ROLE_TYPE.ADMIN
    end

    if roleType == ROLE_TYPE.SPEAKER then
        return ROLE_TYPE.SPEAKER
    end

    if roleType == ROLE_TYPE.DOMESTIC_CONSUMER then
        return ROLE_TYPE.DOMESTIC_CONSUMER
    end
end

local function RegisterEvent()
    local eventManager = require("Base/ZEventDispatchCenter.lua")

    eventManager:RegisterEvent(eventManager.EventType.JOIN_MEETING_RESP, ZPlayer.UpdateUserMeetingInfo)
end

local function UnregisterEvent()
    local eventManager = require("Base/ZEventDispatchCenter.lua")

    eventManager:UnregisterEvent(eventManager.EventType.JOIN_MEETING_RESP, ZPlayer.UpdateUserMeetingInfo)
end

function ZPlayer:Init()
    print("----> ZPlayer.Init")
    RegisterEvent()

end

function ZPlayer:UnInit()
    UnregisterEvent()
    print("----> ZPlayer.UnInit")
end