glua net monitor
1.0.0
一個簡單的實用程序,可捕獲傳出和傳入的網路訊息,以幫助您調試和優化頻寬。支援 net 庫和已棄用的 umsg 庫(如果您仍在使用它,請更新您的插件)。
只需將gLua-net-monitor
資料夾放入garrysmod/addons
資料夾中,它就會自行運行。
覆蓋任何 net/umsg/bf_read 函數覆蓋的插件必須呼叫基本實作才能使其工作。重寫net.Incoming
可能會阻止該實用程式捕獲傳入訊息,因為它需要訊息標頭才能運作。
預設情況下, hooks.lua
檔案包含一些用於調試的基本實作。隨意擺脫它們。
-- Called when a net message is started.
-- @ param msgName: name of the message that was started.
-- @ param funcInfo: info about the function that started the message.
hook . Add ( " OnNetMessageStarted " , " NetStarted " , function ( msgName , funcInfo ) end )
-- Called when a net message is captured, for both outgoing and incoming messages.
-- Keep your code fast in here! This is called for every net/umsg message.
-- @ param msg: The captured message, see NetMonitor.CapturedMessage
-- @ param funcInfo: For outgoing messages, the function who started the message.
hook . Add ( " OnNetMessageCaptured " , " NetCaptured " , function ( msg , funcInfo ) end )
-- Called when a net message is received but no receiving function is hooked.
-- This is likely an oversight of a developer, albeit a wasteful one.
-- @ param msg: The captured message, see NetMonitor.CapturedMessage
hook . Add ( " OnNetMessageIgnored " , " NetIgnored " , function ( msg ) end )
-- Called when a received net message does not read all the received data.
-- Not called for the usermessage lib messages.
-- Called after OnNetMessageCaptured & OnNetMessageIgnored
-- This means you or an addon on your server is wasting bandwidth!
-- @ param msg: The captured message, see NetMonitor.CapturedMessage
-- @note: The captured message data will contain a binary string dump of the remaining data.
hook . Add ( " OnNetMessageDumpedData " , " NetDumped " , function ( msg ) end )
-- Called when a net message is discarded due to starting another without finishing the current one.
-- @ param msg: The captured message which got discarded, likely missing some information.
-- @ param funcInfo: The info about the function which called the dicarded message's net.Start()
hook . Add ( " OnNetMessageDiscarded " , " NetDiscarded " , function ( msg , funcInfo ) end )
-- Called clientside when the server's registry is received.
hook . Add ( " OnNetRegistryUpdated " , " NetRegistryUpdate " , function () end )