local S2C = {}

function S2C:LoginRet(result, reason, userID)
    print(string.format("S2C:LoginRet result:%s reason:%s userID:%s", result, reason, userID))

	local eventManager = require("Base/SEventDispatchCenter.lua")
	eventManager:DispatchEvent(eventManager.EventType.NET_LOGIN_RET, result, reason)

	if not result then
		CS.UnityEngine.Debug.LogWarning("S2C.LoginRet Failed!")
		return
	end

	local languageConfig = require("Config/SConfigManager.lua"):GetConfig("languageConfig")
	-- ShowDialogOK(languageConfig["login"]["login_success"])
end

-- About Sync Info Start
function S2C:SyncDataStart()
	print(string.format("S2C:SyncDataStart"))
	-- local UIHelper = require("Base/UIHelper.lua")
    -- UIHelper:OpenUI("UI/Home/SUIHomePanel.lua")
	-- UIHelper:CloseUI("UI/Login/SUILoginPanel.lua")
end

function S2C:SyncServerTime(syncStep, serverTime)
	print(string.format("S2C:SyncServerTime serverTime:%s ", serverTime))

	local nowTime, _ = require("Base/Utils.lua"):TimeNow()
	local eventManager = require("Base/SEventDispatchCenter.lua")
	eventManager:DispatchEvent(eventManager.EventType.NET_UPDATE_SERVER_TIME, serverTime, nowTime)

	-- local totalPercent = syncStep.percent
	-- local tipsInfo = syncStep.tips
	-- eventManager:DispatchEvent(eventManager.EventType.UI_UPDATE_SYNC_STEP, totalPercent, tipsInfo)
end

function S2C:SyncBaseData(syncStep, userID, name, level, createTime, baseData)
	print(string.format(
		"S2C:SyncBaseData userID:%s name:%s level:%s createTime:%s percnet:%d tips:%s",
		userID, name, level ,createTime, syncStep.percent, syncStep.tips
	))

	local eventManager = require("Base/SEventDispatchCenter.lua")
	eventManager:DispatchEvent(eventManager.EventType.NET_UPDATE_BASE_DATA, userID, name, level, createTime, baseData)

	local totalPercent = syncStep.percent
	local tipsInfo = syncStep.tips
	eventManager:DispatchEvent(eventManager.EventType.UI_UPDATE_SYNC_STEP, totalPercent, tipsInfo)
end

return S2C