RakNet

RakNetSignalConnection.Disconnect

Disconnects a connection returned by RakNet.OnPacketSend.Connect or RakNet.OnPacketReceive.Connect.

Syntax

RakNetSignalConnection.Disconnect(connection: RakNetSignalConnection)

Arguments

NameTypeDescription
connectionRakNetSignalConnectionConnection object returned by a RakNet packet signal Connect call.

Description

Disconnects a connection returned by RakNet.OnPacketSend.Connect or RakNet.OnPacketReceive.Connect. The method returns no values.

Call it with 1 parameter(s): connection. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Disconnect a RakNet packet signal connection.

if RakNet.is_enabled then
    local connection = RakNet.OnPacketSend:Connect(function(packet)
        print(packet.Size)
    end)

    connection:Disconnect()
    print(connection.Connected)
end

Types

RakNetSignalConnection

Connection object returned by RakNet.OnPacketSend.Connect and RakNet.OnPacketReceive.Connect.

Disconnect () -> () Removes the connection from the packet signal.Connected boolean true while the connection still exists for the current RakNet hook generation.