local C2S = {}

local function SendData(msgType, data)
    local jsonConvert = require("Base/json.lua")
    local message = jsonConvert:encode(data)

    if msgType ~= "HEARTBEAT" then
        local _, szTimeFormat = require("Base/Utils.lua"):TimeNow()
        print("----> C2S: message: szTimeFormat:", szTimeFormat, msgType, message)
    end

    local rpcId = CS.LuaSocketManager.Send(msgType, message)
    -- if rpcId == 0, there is a error on send. ignore this messsage.
    if rpcId ~= 0 then
        require("Network/NetworkQueue.lua"):PushUidOnSend(rpcId)
    end
end

function C2S:HeartBeat()
    local data = {
        ["ping"] = true,
    }
    SendData("HEARTBEAT", data)
end

return C2S