Skip to main content

class LightshipNetcodeTransport

(Niantic.Lightship.SharedAR.Netcode.LightshipNetcodeTransport)

Overview​

Lightship's Netcode for GameObjects compatibility layer. Implemented using the Room and INetworking apis.

	class LightshipNetcodeTransport: NetworkTransport {
public:

struct CachedEvent;
struct NetcodeSessionStats;

// properties

override ulong ServerClientId;

// methods

NetcodeSessionStats GetNetcodeSessionStats();

override void Send(
ulong clientId,
ArraySegment<byte> data,
NetworkDelivery delivery = NetworkDelivery.Reliable
);

override NetworkEvent PollEvent(
out ulong clientId,
out ArraySegment<byte> payload,
out float receiveTime
);

void SetRoom(IRoom room);
override bool StartClient();
override bool StartServer();
override void DisconnectRemoteClient(ulong clientId);
override void DisconnectLocalClient();
override ulong GetCurrentRtt(ulong clientId);
override void Shutdown();
override void Initialize(NetworkManager manager);
uint GetLastNetworkError();
};

Detailed Documentation​

Lightship's Netcode for GameObjects compatibility layer. Implemented using the Room and INetworking apis.

Properties​

ServerClientId​

override ulong ServerClientId

A constant netcode clientId that represents the server When this value is found in methods such as Send, it should be treated as a placeholder that means the server

    Parameters:

    networkManager - NetworkManager managing the netcode session

Methods​

GetNetcodeSessionStats​

NetcodeSessionStats GetNetcodeSessionStats()

Poll the current stats of the active netcode session.

Send​

override void Send(
ulong clientId,
ArraySegment<byte> data,
NetworkDelivery delivery = NetworkDelivery.Reliable
)

Send a payload to the specified clientId, data and networkDelivery.

    Parameters:

    clientId - The clientId to send to

    payload - The data to send

    networkDelivery - The delivery type (QoS) to send data with

PollEvent​

override NetworkEvent PollEvent(
out ulong clientId,
out ArraySegment<byte> payload,
out float receiveTime
)

Polls for incoming events, with an extra output parameter to report the precise time the event was received.

    Parameters:

    clientId - The clientId this event is for

    payload - The incoming data payload

    receiveTime - The time the event was received, as reported by Time.realtimeSinceStartup.

    Returns:

    Returns the event type

SetRoom​

void SetRoom(IRoom room)

Set the Lightship Room that we want to use Netcode for Gameobjects in. Set this before calling "StartClient" or "StartServer".

StartClient​

override bool StartClient()

Connects client to the server

    Returns:

    Returns success or failure

StartServer​

override bool StartServer()

Starts to listening for incoming clients

    Returns:

    Returns success or failure

DisconnectRemoteClient​

override void DisconnectRemoteClient(ulong clientId)

Disconnects a client from the server

    Parameters:

    clientId - The clientId to disconnect

DisconnectLocalClient​

override void DisconnectLocalClient()

Disconnects the local client from the server

GetCurrentRtt​

override ulong GetCurrentRtt(ulong clientId)

Gets the round trip time for a specific client. This method is not implemented for Lightship

    Parameters:

    clientId - The clientId to get the RTT from

    Returns:

    Returns 0 always

Shutdown​

override void Shutdown()

Shuts down the transport

Initialize​

override void Initialize(NetworkManager manager)

Initializes the transport. Automatically called by Netcode.

    Parameters:

    networkManager - NetworkManager managing the netcode session

GetLastNetworkError​

uint GetLastNetworkError()

Get error code from the last network error. If no error, returns 0. Error codes are defined as const in Niantic.Lightship.SharedAR.Networking.NetworkEventErrorCode

    Returns:

    Error code