GetNetworkStats: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Client examples) |
||
Line 23: | Line 23: | ||
===Returns=== | ===Returns=== | ||
Returns a table | Returns a table, the indexes in the table are the following: | ||
* "bytesReceived" | * "bytesReceived" | ||
Line 38: | Line 38: | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | |||
This example outputs the local players network status information to their console when using the /netstatus command | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function netStatus() | |||
for index, value in pairs(getNetworkStats()) do | |||
outputConsole(index..": "..value) | |||
end | |||
outputChatBox("Network status output to console", 0, 255, 0) | |||
end | |||
addCommandHandler("netstatus", netStatus) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
This example outputs a warning to local player if packet loss occured in the last second | |||
<syntaxhighlight lang="lua"> | |||
function packetLossCheck() | |||
local loss = getNetworkStats()["packetlossLastSecond"] | |||
if (loss > 0) then | |||
outputChatBox("Packet loss detected when communicating with server, gameplay may be affected", 255, 0, 0) | |||
end | |||
end | |||
setTimer(packetLossCheck, 1000, 0) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Client_utility_functions}} | {{Client_utility_functions}} |
Revision as of 14:14, 12 August 2011
This function returns network status information.
Available in 1.1 and onwards
Syntax
Click to collapse [-]
Clienttable getNetworkStats ( )
Click to collapse [-]
Servertable getNetworkStats ( [ element thePlayer = nil ] )
Optional Arguments
- thePlayer: The player you want to retrieve network stats from.
Returns
Returns a table, the indexes in the table are the following:
- "bytesReceived"
- "bytesSent"
- "packetsReceived"
- "packetsSent"
- "packetlossTotal"
- "packetlossLastSecond"
- "messagesInSendBuffer"
- "messagesInResendBuffer"
- "isLimitedByCongestionControl"
- "isLimitedByOutgoingBandwidthLimit"
- "encryptionStatus"
Example
Click to collapse [-]
ClientThis example outputs the local players network status information to their console when using the /netstatus command
function netStatus() for index, value in pairs(getNetworkStats()) do outputConsole(index..": "..value) end outputChatBox("Network status output to console", 0, 255, 0) end addCommandHandler("netstatus", netStatus)
This example outputs a warning to local player if packet loss occured in the last second
function packetLossCheck() local loss = getNetworkStats()["packetlossLastSecond"] if (loss > 0) then outputChatBox("Packet loss detected when communicating with server, gameplay may be affected", 255, 0, 0) end end setTimer(packetLossCheck, 1000, 0)
See Also
- createTrayNotification
- downloadFile
- getDevelopmentMode
- getKeyboardLayout
- getLocalization
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- setClipboard
- setDevelopmentMode
- setTransferBoxVisible
- setWindowFlashing
- showCol
- showSound
- Shared
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace