MainMateTable.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. local cjson = require("cjson")
  2. local function pluginDataUpLog(reasonEvent)
  3. if not reasonEvent then
  4. return
  5. end
  6. -- body
  7. local platform = "pc"
  8. local userId = ""
  9. local channelId = global.L_GameEnvManager:GetChannelID()
  10. local gameId = ""
  11. local roleId = ""
  12. local roleName = ""
  13. local job = ""
  14. local sex = ""
  15. local clientVesion = ""
  16. local mapId = ""
  17. local serverId = ""
  18. local serverName = ""
  19. if cc.PLATFORM_OS_ANDROID == global.Platform then
  20. platform = "android"
  21. elseif global.isOHOS then
  22. platform = "ohos"
  23. elseif cc.PLATFORM_OS_IPAD == global.Platform or cc.PLATFORM_OS_IPHONE == global.Platform then
  24. platform = "ios"
  25. end
  26. local AuthProxy = global.Facade and global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  27. local currModule = global.L_ModuleManager:GetCurrentModule()
  28. local loginProxy = global.Facade and global.Facade:retrieveProxy( global.ProxyTable.Login )
  29. local propertyProxy = global.Facade and global.Facade:retrieveProxy( global.ProxyTable.PlayerProperty )
  30. local mapProxy = global.Facade and global.Facade:retrieveProxy( global.ProxyTable.Map )
  31. gameId = currModule:GetOperID()
  32. if AuthProxy then
  33. userId = AuthProxy:GetUID()
  34. end
  35. if loginProxy then
  36. roleId = loginProxy:GetSelectedRoleID()
  37. roleName = loginProxy:GetSelectedRoleName()
  38. serverId = loginProxy:GetSelectedServerId()
  39. serverName = loginProxy:GetSelectedServerName()
  40. end
  41. if propertyProxy then
  42. job = tostring( GetJobName(propertyProxy:GetRoleJob()) )
  43. sex = tostring( propertyProxy:GetRoleSex() + 1 )
  44. clientVesion= currModule:GetRemoteVersion()
  45. end
  46. if mapProxy then
  47. mapId = mapProxy:GetMapID()
  48. end
  49. local upLogData = {
  50. event={time=os.time(),name = "plugin_event",type = "track"},
  51. user={id=tostring( userId )},
  52. properities = {
  53. game_platform = platform,
  54. user_id = userId,
  55. platform_id = channelId,
  56. game_id = gameId,
  57. role_id = roleId,
  58. role_name = roleName,
  59. job_name = job,
  60. gender = sex,
  61. client_vesion = clientVesion,
  62. map_id = mapId,
  63. servid = serverId,
  64. server_name = serverName,
  65. reason = reasonEvent
  66. }
  67. }
  68. global.L_DataRePort:SendRePortData(upLogData)
  69. end
  70. if cc.PLATFORM_OS_ANDROID == global.Platform or cc.PLATFORM_OS_WINDOWS == global.Platform then
  71. local WebSocket = cc.WebSocket
  72. function WebSocket:create(data)
  73. pluginDataUpLog("websocket")
  74. return getmetatable(self)[".backup"].create(self, data)
  75. end
  76. end