This commit is contained in:
aixianling
2024-12-13 13:41:02 +08:00
commit 06658f112f
3887 changed files with 2687822 additions and 0 deletions

View File

@@ -0,0 +1,320 @@
--[[
激活码功能
个人数据CdKeyData
{
lastTime,上次使用时间
codeTimes =
{
[id1], 礼包id1的使用次数
[id2],
}
}
[60] = {
Id = 60,
awards = {{type=0,id=1270,count=1},{type=0,id=1271,count=1}},
limits = 1,
mailtitle = "VIP进游礼包",
mailcontent = "礼包兑换成功,这是为您准备的礼包,请收好",
switch = 1,
},
[61] = {
Id = 61,
awards = {{type=0,id=1242,count=33},{type=0,id=388,count=1},{type=0,id=1248,count=10}},
limits = 1,
mailtitle = "特权资源礼包",
mailcontent = "礼包兑换成功,这是为您准备的礼包,请收好",
switch = 1,
},
]]
local CODE_SUCCESS = 0 -- 成功
local CODE_INVALID = 1 -- 已被使用
local CODE_NOTEXIST = 2 -- 不存在
local CODE_USED = 3 -- 已使用过同类型
local CODE_ERR = 4 -- SQL查询错误
local CODE_TIME = 5 -- 未到使用时间
local CODE_TIMEEXPIRE = 6 -- 礼包码过期了
local CODE_HTTP = 11 -- HTTP接口错误
local CODE_PF = 12 -- 非本平台礼包码
local CODE_LIMIT = 13 -- 使用次数超过限制
local PfId = System.getPfId()
local SrvId = System.getServerId()
local ServiceConf = CdkeyServiceConf[PfId]
--配置的服务检测
function OnCheckCanPlatform()
-- 平台验证
if not PfId then
print("[ERR][CdKey old]0 load CdkeyServiceConfig error! ")
return false
end
if ServiceConf == nil then
print("[ERR][CdKey old]1 load CdkeyServiceConfig error! ")
return false
end
if ServiceConf.host == nil then
print("[ERR][CdKey old]2 load CdkeyServiceConfig error! ")
return false
end
if ServiceConf.port == nil then
print("[ERR][CdKey old]3 load CdkeyServiceConfig error! ")
return false
end
if ServiceConf.url == nil then
print("[ERR][CdKey old]4 load CdkeyServiceConfig error! ")
return false
end
return true
end
-- 根据 CDKey 获取礼包码id
local function getCodeId(code)
local len = string.byte(string.sub(code, -1)) - 97
local pos = string.byte(string.sub(code, -2,-2)) - 97
local str = string.sub(code, pos + 1, pos + len)
--print("gift code len :"..tostring(len))
---print("gift code pos :"..tostring(pos))
--print("gift code str :"..tostring(str))
local id = 0
for i=1, string.len(str) do
id = id * 10 + (math.abs(string.byte(string.sub(str, i, i)) - 97))
end
return id
end
-- 检测平台号
local function checkPfid(code)
local pos = string.byte(string.sub(code, -2,-2)) - 97
local str = string.sub(code, 1, pos)
return str == PfId
end
-- 获取玩家的 CDKey 数据
local function getActorData(pActor)
if Actor.getEntityType(pActor) ~= enActor then
assert(false)
end
local var = Actor.getStaticVar(pActor);
if var.CdKeyData == nil then
var.CdKeyData = {}
end
if not var.CdKeyData.codeTimes then
var.CdKeyData.codeTimes = {}
end
return var.CdKeyData
end
-- 获取玩家的 CDKey 数据
function getActorCdkData(pActor)
if Actor.getEntityType(pActor) ~= enActor then
assert(false)
end
local var = Actor.getStaticVar(pActor);
if var.CdKeyData == nil then
var.CdKeyData = {}
end
if not var.CdKeyData.codeTimes then
var.CdKeyData.codeTimes = {}
end
if not var.CdKeyData.codeTypeTimes then
var.CdKeyData.codeTypeTimes = {}
end
return var.CdKeyData
end
-- 检测完CDKey后的回调
local function AfterCheckCDkey(paramPack,content,result)
print("[TIP] AfterCheckCDkey : content("..content.."), result: "..result)
local aid = paramPack[1]
local id = paramPack[2]
local pActor = Actor.getActorById(aid)
local res = CODE_SUCCESS
local giftid = id
if pActor and (result == 0) then
-- 获取结果
res,giftid = string.match(content, "(%d+),(%d+)")
res = tonumber(res)
giftid = tonumber(giftid)
if res ~= nil then
if res == CODE_SUCCESS then
-- 发派奖励
local conf = CDKeyConf[id]
SendMail(aid, conf.mailtitle or "兑换码", conf.mailcontent or "兑换码兑换成功!", conf.awards)
-- 记录使用
local data = getActorData(pActor)
data.codeTimes[id] = (data.codeTimes[id] or 0) + 1
if not data.codeTypeTimes then
data.codeTypeTimes = {}
end
data.codeTypeTimes[giftid] = (data.codeTypeTimes[giftid] or 0) + 1
end
else
res = CODE_HTTP
print("[ERROR] AfterCheckCDkey : res("..res.."), content: "..content)
end
else
res = CODE_HTTP
print("[ERROR] AfterCheckCDkey : result("..result.."), content: "..content)
end
-- 回复使用结果
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, res)
DataPack.flush(npack)
end
end
--使用激活码
function UseCDKey(pActor, code)
print("[DEBUG] UseCDKey, code="..code)
local ServiceHost = ServiceConf.host
local ServicePort = ServiceConf.port
local ServiceUrl = ServiceConf.url
if checkPfid(code) == false then
--Actor.sendTipmsg(pActor,"非本平台的礼包码!")
-- 回复使用结果
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, CODE_PF)
DataPack.flush(npack)
end
return
end
local data = getActorData(pActor)
local time = System.getCurrMiniTime()
if data.lastTime and data.lastTime >= time then
Actor.sendTipmsg(pActor,"请求过快!")
return
end
local id = getCodeId(code)
if CDKeyConf[id] == nil then
Actor.sendTipmsg(pActor, "礼包码错误02")
print("[ERROR] getCodeId error : code = " .. code.."id = " .. id.." name="..Actor.getName(pActor))
return
end
local limit = CDKeyConf[id].limits or 1 --礼包码限制数量
if data.codeTimes[id] then
if data.codeTimes[id] >= limit then
--Actor.sendTipmsg(pActor,"使用次数超过限制!")
-- 回复使用结果
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, CODE_LIMIT)
DataPack.flush(npack)
end
return
end
end
--加入异步工作
local account = Actor.getAccount(pActor)
local aid = Actor.getActorId(pActor)
local req = ServiceUrl..'?pfid='..PfId..'&cdkey='..code..'&aid='..aid..'&sid='..SrvId..'&account='..account..'&limit='..limit
print("[TIP] [CdKey] GetHttpContent -------------------------ServiceHost:"..tostring(ServiceHost))
print("[TIP] [CdKey] GetHttpContent -------------------------ServicePort:"..tostring(ServicePort))
print("[TIP] [CdKey] GetHttpContent -------------------------req:"..tostring(req))
print("[TIP] getCodeId error : code = " .. code.."id = " .. id.." name="..Actor.getName(pActor))
AsyncWorkDispatcher.Add(
{'GetHttpContent', ServiceHost, ServicePort, req},
AfterCheckCDkey,
{aid,id}
)
end
--使用通码
function UseCommonCDKey(pActor, code)
print("[DEBUG] UseCommonCDKey, code="..code)
local data = getActorData(pActor)
local time = System.getCurrMiniTime()
if data.lastTime and data.lastTime >= time then
Actor.sendTipmsg(pActor,"请求过快!")
return
end
if CommonCDKeyConf[code].switch == 0 then
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, CODE_TIMEEXPIRE)
DataPack.flush(npack)
end
return
end
-- 使用次数超过限制
if data.codeTimes[code] then
if data.codeTimes[code] >= 1 then
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, CODE_LIMIT)
DataPack.flush(npack)
end
return
end
end
-- 发派奖励
local conf = CommonCDKeyConf[code]
local aid = Actor.getActorId(pActor)
SendMail(aid, conf.mailtitle or "兑换码", conf.mailcontent or "兑换码兑换成功!", conf.awards)
-- 记录使用
local data = getActorData(pActor)
data.codeTimes[code] = (data.codeTimes[code] or 0) + 1
-- 回复使用结果
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
if npack then
DataPack.writeByte(npack, CODE_SUCCESS)
DataPack.flush(npack)
end
end
--是否是通码
function isCommonKey(code)
if CommonCDKeyConf and CommonCDKeyConf[code] then
return true
end
return false
end
-- 客户端请求使用激活码
function OnUseCDKey(pActor, packet)
print("[DEBUG] OnUseCDKey, PfId="..PfId)
if OnCheckCanPlatform() == false then
print("[DEBUG] OnUseCDKey, OnCheckCanPlatform() == false")
return
end
local code = DataPack.readString(packet)
print("[DEBUG][Tip] OnUseCDKey: code = " .. code)
if isCommonKey(code) then
UseCommonCDKey(pActor, code)
else
UseCDKey(pActor,code)
end
end
NetmsgDispatcher.Reg(enMiscSystemID, cUseCdkey, OnUseCDKey)

View File

@@ -0,0 +1,358 @@
--module("PcDownLoadGift", package.seeall)
--[[
微端功能 个人数据
PcClientData = {
pcGift
}
]]
local FcmServiceHostHttp = "http://fcmds.sdo.com"
local FcmServiceHost = "fcmds.sdo.com" ---/http://fcmds.sdo.com/heartbeat //"devops.191game.com"
local FcmServicePort = "80"
local FcmHeartbeateUrl = "/heartbeat"
local FcmUseroffline = "/useroffline"
local FcmUseronline = "/useronline"
local Fcmappid = "1100012"
local FcmSecretkey = "01mbv7nqqj4f34m7zjnd14a9zfamvphx"
local FcmAccounttype = 1
local FcmMerchant_name = "1_1100012_7429"
local FcmSignature_method = "MD5"
local FcmIpadd = "16777343"
local FcmSevPort = 443
PlatformConfig = NativeRewardConfig
local PfId = System.getPfId()
function getActorPcClientData(pActor)
if Actor.getEntityType(pActor) ~= enActor then
assert(false)
end
local var = Actor.getStaticVar(pActor);
if var.PcClientData == nil then
var.PcClientData = {}
end
return var.PcClientData
end
function OnPcDownLoadGift(pActor, packet)
if PfId ~= nil and PlatformConfig.SPID ~= nil and table.getn(PlatformConfig.SPID) > 0 then
--print("[Tip] [PlatformQQ] SendQQHallData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
local Can = 0
for k, v in ipairs(PlatformConfig.SPID) do
-- print(k,v)
--print("[Tip] [NativeRewardConfig] NativeRewardConfig333 ---------------- SPID MSG:"..tostring(v))
if tostring(PfId) == tostring(v) then
Can = Can + 1
end
end
--print("[Tip] [NativeRewardConfig] NativeRewardConfig444 ---------------- SPID count:"..tostring(Can))
if Can == 0 then
print("[Tip] [NativeRewardConfig] [非本平台活动]")
return --非本平台活动
end
end
local data = getActorPcClientData(pActor)
if data.pcGift then
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已领取|", tstUI)
return
end
local conf = PlatformConfig
if conf and conf.reward then
CommonFunc.Awards.Give(pActor, conf.reward, GameLog.Log_PcGift)
end
data.pcGift = 1;
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
SendPcClientState(pActor);
Actor.setStaticCount(pActor, 10005, 1);
local strName = Actor.getName(pActor)
if conf and conf.tips then
local strTips = string.format(conf.tips,strName)
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
end
if conf and conf.tips2 then
local strTipm2 = string.format(conf.tips2,strName)
System.broadcastTipmsgLimitLev(strTipm2, tstChatSystem)
end
end
function SendPcClientState(pActor)
local npack = DataPack.allocPacket(pActor, enDefaultEntitySystemID, sPcClientDownLoadState)
if npack then
-- print("1111")
local data = getActorPcClientData(pActor)
DataPack.writeByte(npack, (data.pcGift or 0)) --
DataPack.flush(npack)
end
end
-- 回调
local function AfterGetHttpContent(paramPack, content, result)
local aid = paramPack[1]
print("[Tip] [SQFcm] AfterGetHttpContent --------------------------aid:"..aid.."------------------- content:"..tostring(content))
--测试数据local strContent00 = "{\"return_code\":-10250031,\"return_message\":\"Server reject, no authority, remote ip is 49.234.73.200\",\"data\":{}}"
local strPattern11 = "^(.*)(return_code%s*\"%s*)(%b:,)(.*)$"
local strPattern22 = "^(.*)(return_message\"%s*:%s*)(%b\"\")(.*)$"
--local strContent = "abcde csdn = {博客} csdn.net"
--local strPattern = "^(.*)(csdn%s*=%s*)(%b{})(.*)$"
--local strCapture1, strCapture2, strCapture3, strCapture4 = string.match(strContent, strPattern)
--print("t------"..tostring(strCapture1).."------"..tostring(strCapture2).."------"..tostring(strCapture3).."------"..tostring(strCapture4))
if result == 0 then
local strCapture1, strCapture2, return_code, strCapture3, strCapture4 = string.match(content, strPattern11)
local strCapture1, strCapture2, return_message, strCapture4 = string.match(content, strPattern22)
--local return_code = string.match(strContent00,"return_code\":-(%a+),\"return")
--local return_message = string.match(strContent00,"return_message\":\"(%a+)\",\"")
--code = (string.gsub(return_code, "^[%s\n\r\t]*(.-)[%s\n\r\t]*$", "%1"))
--message = (string.gsub(return_message, "^[%s\n\r\t]*(.-)[%s\n\r\t]*$", "%1"))
--code = string.match(return_code,":%s+,")
--message = string.match(return_message, "\"%s+\"")
print("[Tip] [SQFcm] AfterGetHttpContent ----------return_code:"..tostring(return_code) )
print("[Tip] [SQFcm] AfterGetHttpContent ---------return_message:"..tostring(return_message) )
--print("[return_code-----------------------------------------------------------------------return_code:"..tostring(code) )
--print("[return_message--------------------------------------------------------------------return_message:"..tostring(message) )
end
end
local function GetHttpContentOnline(paramPack, content, result)
local aid = paramPack[1]
print("[Tip] [SQFcm] GetHttpContentOnline --------------------------aid:"..aid.."------------------- content:"..tostring(content))
local strPattern11 = "^(.*)(return_code%s*\"%s*)(%b:,)(.*)$"
local strPattern22 = "^(.*)(return_message\"%s*:%s*)(%b\"\")(.*)$"
if result == 0 then
local strCapture1, strCapture2, return_code, strCapture3, strCapture4 = string.match(content, strPattern11)
local strCapture1, strCapture2, return_message, strCapture4 = string.match(content, strPattern22)
print("[Tip] [SQFcm] GetHttpContentOnline ----------return_code:"..tostring(return_code) )
print("[Tip] [SQFcm] GetHttpContentOnline ---------return_message:"..tostring(return_message) )
if(tostring(return_code) == ": 0,") then
local strPattern33 = "^(.*)(remainingTime%s*\"%s*)(%b:,)(.*)$"
local str1, str2, remainingTime, str4 = string.match(content, strPattern33)
print("[Tip] [SQFcm] GetHttpContentOnline ----------remainingTime:"..tostring(remainingTime))
if remainingTime == nil then
return
end
local sscount = string.len(remainingTime)
if(sscount > 2) then
res = string.sub(remainingTime, 2, sscount - 1)
print("[GetHttpContentOnline---------------------------------remainingTime = :"..tostring(res))
local remaining = tonumber(res)
local pActor = Actor.getActorById(actorid)
--Actor.changeFcmTime(pActor, remaining)
print("[Tip] [SQFcm] GetHttpContentOnline ----------remainingTime"..tostring(remaining))
end
end
end
end
-- 防沉迷
function OnFcmUseOnline(pActor, packet)
local ntype = DataPack.readByte(packet)
local nMsg = DataPack.readByte(packet)
local nSub = DataPack.readByte(packet)
--local ServerIndex = DataPack.readint(packet)
print("[Tip] [SQFcm] OnFcmUseOnline -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub) )
--local AccountName = DataPack.readString(packet)
--local code = DataPack.readString(packet)
--print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
--加入异步工作
--local account = Actor.getAccount(pActor)
--local aid = Actor.getActorId(pActor)
--即时生成
local eventtime = System.getCurrMiniTime()
local match_eventtime = os.date("%Y-%m-%d %H:%M:%S", os.time())
local characterid = Actor.getName(pActor);
local PfId = System.getPfId()
local SrvId = System.getServerId()
local account = 'om00748880396.pt'--Actor.getAccount(pActor)--盛趣正式账号 om00748880396.pt'om00748880396.pt'--
local aid = Actor.getActorId(pActor)
local str_guid = System.MD5(tostring(eventtime))
--local nYear, nMonth, nDay
--System.getDate(nYear, nMonth, nDay)
--local nHour, nMinute, nSecond, nMiliSecond
--System.getTime(nHour, nMinute, nSecond, nMiliSecond)
--print("[OnFcmUseOnline--eventtime------------------------------------"..tostring(eventtime))
--print("[OnFcmUseOnline--str_guid------------------------------------"..tostring(str_guid))
--固定
local reqSign = 'accounttype='..FcmAccounttype..'&appid='..Fcmappid..'&areaid='..'1'..'&characterid='..aid..'&endpointip='..FcmIpadd..'&endpointport='..FcmSevPort..'&eventtime='..match_eventtime..'&groupid='..SrvId..'&guid='..tostring(str_guid)..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'&timestamp='..tostring(eventtime)..'&userid='..tostring(account)
local reqSign1 = 'accounttype='..FcmAccounttype..'appid='..Fcmappid..'areaid='..'1'..'characterid='..aid..'endpointip='..FcmIpadd..'endpointport='..FcmSevPort..'eventtime='..match_eventtime..'groupid='..SrvId..'guid='..tostring(str_guid)..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)..'userid='..tostring(account)
local sign = System.MD5(tostring(reqSign1..FcmSecretkey))
--print("[OnFcmUseOnline--reqSign1-----------------reqSign1Size:-------------------"..string.len(tostring(reqSign1..FcmSecretkey)))
print("[Tip] [SQFcm] OnFcmUseOnline -------------------------reqSign:"..tostring(reqSign1))
print("[Tip] [SQFcm] OnFcmUseOnline -------------------------FcmSecretkey:"..tostring(FcmSecretkey))
print("[Tip] [SQFcm] OnFcmUseOnline -------------------------sign:"..tostring(sign))
local req = FcmUseronline..'?'..reqSign..'&signature='..tostring(sign)
AsyncWorkDispatcher.Add(
{'GetHttpContent', FcmServiceHost, FcmServicePort, req},
GetHttpContentOnline,
{aid, 0}
)
end
function OnFcmUseOffline(pActor, packet)
local ntype = DataPack.readByte(packet)
local nMsg = DataPack.readByte(packet)
local nSub = DataPack.readByte(packet)
print("[Tip] [SQFcm] OnFcmUseOffline -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub) )
--local code = DataPack.readString(packet)
--print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
--即时生成
local eventtime = System.getCurrMiniTime()
local match_eventtime = os.date("%Y-%m-%d %H:%M:%S", os.time())
local characterid = Actor.getName(pActor);
local PfId = System.getPfId()
local SrvId = System.getServerId()
local account = 'om00748880396.pt'--Actor.getAccount(pActor)--'om00748880396.pt'--
local aid = Actor.getActorId(pActor)
local str_guid = System.MD5(tostring(eventtime))
--print("[OnFcmUseOnline--str_guid------------------------------------"..tostring(str_guid))
--固定
local reqSign = 'accounttype='..FcmAccounttype..'&appid='..Fcmappid..'&areaid='..'1'..'&characterid='..aid..'&endpointip='..FcmIpadd..'&endpointport='..FcmSevPort..'&eventtime='..match_eventtime..'&groupid='..SrvId..'&guid='..tostring(str_guid)..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'&timestamp='..tostring(eventtime)..'&userid='..tostring(account)
local reqSign1 = 'accounttype='..FcmAccounttype..'appid='..Fcmappid..'areaid='..'1'..'characterid='..aid..'endpointip='..FcmIpadd..'endpointport='..FcmSevPort..'eventtime='..match_eventtime..'groupid='..SrvId..'guid='..tostring(str_guid)..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)..'userid='..tostring(account)
local sign = System.MD5(tostring(reqSign1..FcmSecretkey))
--print("[OnFcmUseOnline--reqSign1-----------------reqSign1Size:-------------------"..string.len(tostring(reqSign1..FcmSecretkey)))
print("[Tip] [SQFcm] OnFcmUseOffline -------------------------reqSign:"..tostring(reqSign1))
print("[Tip] [SQFcm] OnFcmUseOffline -------------------------FcmSecretkey:"..tostring(FcmSecretkey))
print("[Tip] [SQFcm] OnFcmUseOffline -------------------------sign:"..tostring(sign))
local req = FcmUseroffline..'?'..reqSign..'&signature='..tostring(sign)
AsyncWorkDispatcher.Add(
{'GetHttpContent', FcmServiceHost, FcmServicePort, req},
AfterGetHttpContent,
{aid, 0}
)
end
function OnFcmUseHeatbeat2(ppActor, packet)
local ntype = DataPack.readByte(packet)
local nMsg = DataPack.readByte(packet)
local nSub = DataPack.readByte(packet)
local nCount = DataPack.readByte(packet)
print("[Tip] [SQFcm] OnFcmUseHeatbeat2 -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub) .."nCount"..tostring(nCount) )
local eventtime = System.getCurrMiniTime()
local PfId = System.getPfId()
local SrvId = System.getServerId()
--固定
local reqSign = 'appid='..Fcmappid..'ip='..FcmIpadd..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)
local reqSign1 = 'appid='..Fcmappid..'&ip='..FcmIpadd..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'&timestamp='..tostring(eventtime)
local msghead = "usersinfo=["
local msgItem = ""
for i = 1, nCount do
--print("[OnFcmUseHeatbeat2----------------------------------------i"..tostring(i))
local actorid = DataPack.readUInt(packet)
--print("[OnFcmUseHeatbeat2----------------------------------------i"..tostring(actorid))
local pActor = Actor.getActorById(actorid)
print("[Tip] [SQFcm] OnFcmUseHeatbeat2 usersinfo---------------------- name:"..Actor.getName(pActor).."actorid:"..tostring(actorid))
if pActor == nil then
break
end
local characterid = Actor.getName(pActor);
local account = 'om00748880396.pt'--Actor.getAccount(pActor)
local aid = Actor.getActorId(pActor)
msgItem = msgItem..'{\"areaid\":'..'1'..',\"groupid\":'..SrvId..',\"userid\":\"'..account..'\",\"accounttype\":'..FcmAccounttype..',\"characterid\":\"'..aid..'\"},'
--if(i < nCount)
--{
-- msgItem = msgItem..','
--}
end
if msgItem == "" then
return
end
local msg = msghead..msgItem..']'
local sign = System.MD5(tostring(reqSign..msg..FcmSecretkey))
local req = FcmHeartbeateUrl..'?'..reqSign1..'&signature='..tostring(sign)
print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------reqSign:"..tostring(reqSign1))
print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------FcmSecretkey:"..tostring(FcmSecretkey))
print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------sign:"..tostring(sign))
local str = string.format("POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s", req, FcmServiceHost, string.len(msg), msg)
---AsyncWorkDispatcher.Add({'Test', 1,2},AfterGetHttpContent,{expect=1+1})
AsyncWorkDispatcher.Add(
{'PostHttpContent2', FcmServiceHost, FcmServicePort, str},
AfterGetHttpContent,
{aid, 0}
)
print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------msghead:"..tostring(msghead))
end
function OnFcmUseHeatbeat(pActor, packet)
local ntype = DataPack.readByte(packet)
local nMsg = DataPack.readByte(packet)
local nSub = DataPack.readByte(packet)
-- print("[OnFcmUseHeatbeat----------------------------------------------------------------------- id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub) )
local code = DataPack.readString(packet)
-- print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
--即时生成
local eventtime = System.getCurrMiniTime()
local characterid = Actor.getName(pActor);
local PfId = System.getPfId()
local SrvId = System.getServerId()
local account = Actor.getAccount(pActor)
local aid = Actor.getActorId(pActor)
--固定
local reqSign = 'appid='..Fcmappid..'ip='..FcmIpadd..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)
local reqSign1 = 'appid='..Fcmappid..'&ip='..FcmIpadd..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'&timestamp='..tostring(eventtime)
local msg = 'usersinfo=[{\"areaid\":'..'1'..',\"groupid\":'..SrvId..',\"userid\":\"'..account..'\",\"accounttype\":'..FcmAccounttype..',\"characterid\":\"'..aid..'\"}]'
local sign = System.MD5(tostring(reqSign..msg..FcmSecretkey))
local req = FcmHeartbeateUrl..'?'..reqSign1..'&signature='..tostring(sign)
-- print("[OnFcmUseHeatbeat--reqSign1------------------------------------"..tostring(reqSign1))
--print("[OnFcmUseHeatbeat--FcmSecretkey------------------------------------"..tostring(FcmSecretkey))
--print("[OnFcmUseHeatbeat--sign------------------------------------"..tostring(sign))
local str = string.format("POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s", req, FcmServiceHost, string.len(msg), msg)
---AsyncWorkDispatcher.Add({'Test', 1,2},AfterGetHttpContent,{expect=1+1})
AsyncWorkDispatcher.Add(
{'PostHttpContent2', FcmServiceHost, FcmServicePort, str},
AfterGetHttpContent,
{aid, 0}
)
end
NetmsgDispatcher.Reg(enDefaultEntitySystemID, cGetPcClientDownLoadGift, OnPcDownLoadGift)
-- 防沉迷
NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseOnline, OnFcmUseOnline)
NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseOffline, OnFcmUseOffline)
--NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseHeatbeat, OnFcmUseHeatbeat)
NetmsgDispatcher.Reg(enMiscSystemID, sFcmAllUseHeatbeat, OnFcmUseHeatbeat2)