nc:IsNull():booleanWhether the channel is null.
The net channel: latency, loss, and connection details.
nc:IsNull():booleanWhether the channel is null.
nc:GetName():stringChannel name.
nc:GetAddress():stringRemote address string.
nc:GetConnectTime():numberTime the connection was established.
nc:GetTimeSinceLastReceived():numberSeconds since the last received packet.
nc:GetLatency(flow:number):numberLatency in seconds; flow 0 = incoming, 1 = outgoing.
nc:GetAvgLatency(flow:number):numberAverage latency; flow 0 = incoming, 1 = outgoing.
nc:GetAvgChoke(flow:number):numberAverage choke; flow 0 = incoming, 1 = outgoing.
nc:GetAvgLoss(flow:number):numberAverage loss; flow 0 = incoming, 1 = outgoing.
nc:GetAvgData(flow:number):numberAverage data rate; flow 0 = incoming, 1 = outgoing.
nc:GetTime():numberCurrent time on the channel.
nc:GetTimeConnected():numberSeconds since the connection started.
nc:GetBufferSize():numberCurrent buffer size in bytes.
nc:GetDataRate():numberMaximum data rate in bytes per second.
nc:IsLoopback():booleanWhether the channel is a loopback connection.
nc:IsTimingOut():booleanWhether the channel is timing out.
nc:IsPlayback():booleanWhether the channel is in playback mode.
nc:SetDataRate(rate:number)Set the maximum data rate.
nc:SetTimeout(t:number)Set the connection timeout in seconds.
nc:SetChallengeNr(nr:number)Set the challenge number.
nc:GetChallengeNr():numberCurrent challenge number.
nc:GetSequenceData():number, number, numberIncoming sequence state (inRelState, inNr, inStreamSeqNr).
nc:SetSequenceData(a:number, b:number, c:number)Set the incoming sequence state.
nc:SetInterpolationAmount(amt:number)Set the interpolation amount.
nc:SendData(buffer:BitBuffer, reliable:boolean):booleanSend a bit buffer over the channel.
Reads the live net channel to draw ping, choke and loss in a corner.
callbacks.Register("Draw", function()
local nc = clientstate.GetNetChannel()
if not nc or nc:IsNull() then return end
-- flow 0 = incoming, 1 = outgoing; latency is in seconds
local ping = (nc:GetLatency(0) + nc:GetLatency(1)) * 1000
draw.Color(255, 255, 255, 255)
draw.Text(10, 46, string.format("ping %.0fms choke %.1f%% loss %.1f%%",
ping, nc:GetAvgChoke(1) * 100, nc:GetAvgLoss(1) * 100))
end)
Prints the server address and connection time once, right after joining.
local printed = false
callbacks.Register("Draw", function()
if printed then return end
local nc = clientstate.GetNetChannel()
if not nc or nc:IsNull() then return end
printed = true
print("server:", nc:GetAddress())
print("loopback:", tostring(nc:IsLoopback()))
print("connected for:", string.format("%.1fs", nc:GetTimeConnected()))
end)