RakNetConnection: Disconnect Synchronous
RakNetConnection:disconnect
Stop a packet signal connection from receiving future events. Use it to clean up a Connect or Once observer when its work is finished.
Luau
RakNetConnection:Disconnect() -> ()Parameters
Call this method with a RakNetConnection receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
This function takes no arguments.
Returns
()No value.
Usage notes
Disconnect is safe to call after a Once listener has already fired. Legacy add_send_hook and add_receive_hook callbacks use their matching remove functions.
Availability
RakNet is disabled by default. RakNet and raknet are removed when the setting is off; retained references can still call is_enabled().
Example
Luau
if raknet.is_enabled() then
local connection = raknet.OnPacketSend:Connect(function(packet)
print(packet.ID)
end)
connection:Disconnect()
print(connection.Connected) -- false
end