LethalNetworkAPI.LNetworkEvent Class
Used to invoke events between clients (and the server/host).
public sealed class LNetworkEvent
Inheritance
↳ System.Object
↳ LNetworkEvent
Remarks
Will not interact with LNetworkMessage<TData>, LNetworkVariable<TData>, nor with other mods - even if the identifier is not unique.
Methods
ClearSubscriptions()
Clear all subscriptions to all callbacks on this LNetworkEvent.
Declaration
public void ClearSubscriptions()
Connect(string, Action<ulong>?, Action?, Action<ulong>?)
Creates a new LNetworkEvent if it doesn't already exist, otherwise returns the existing event of the same identifier.
Declaration
public static LNetworkEvent Connect(string identifier, Action<ulong>? onServerReceived = null, Action? onClientReceived = null, Action<ulong>? onClientReceivedFromClient = null)
Parameters
Type | Name | Description |
---|---|---|
string | identifier | The identifier of the LNetworkEvent. |
Action<ulong>? | onServerReceived | [Opt.] The method to run when the server receives an event. |
Action? | onClientReceived | [Opt.] The method to run when the client receives an event. |
Action<ulong>? | onClientReceivedFromClient | [Opt.] The method to run when the client receives an event from another client. |
Returns
Type | Description |
---|---|
LNetworkEvent | The LNetworkEvent. |
Create(string, Action<ulong>, Action, Action<ulong>)
Creates a new LNetworkEvent. If it already exists, an exception will be thrown.
Declaration
public static LNetworkEvent Connect(string identifier, Action<ulong>? onServerReceived = null, Action? onClientReceived = null, Action<ulong>? onClientReceivedFromClient = null)
Parameters
Type | Name | Description |
---|---|---|
string | identifier | The identifier of the LNetworkEvent. |
Action<ulong>? | onServerReceived | [Opt.] The method to run when the server receives an event. |
Action? | onClientReceived | [Opt.] The method to run when the client receives an event. |
Action<ulong>? | onClientReceivedFromClient | [Opt.] The method to run when the client receives an event from another client. |
Returns
Type | Description |
---|---|
LNetworkEvent | The LNetworkEvent. |
Exceptions
Type | Description |
---|---|
InvalidOperationException | Thrown if the LNetworkMessage<TData> already exists. |
InvokeClient(int)
Server-only method to invoke the event on a specific client.
Declaration
public void InvokeClient(int playerId)
Parameters
Type | Name | Description |
---|---|---|
int | playerId | The in-game ids of the client to invoke the event on. |
InvokeClient(ulong)
Server-only method to invoke the event on a specific client.
Declaration
public void InvokeClient(ulong clientGuid)
Parameters
Type | Name | Description |
---|---|---|
ulong | clientGuid | The NGO guid of the client to invoke the event on. |
InvokeClients()
Server-only method to invoke the event on all clients.
Declaration
public void InvokeClients()
InvokeClients(int[])
Server-only method to invoke the event on the specified clients.
Declaration
public void InvokeClients(int[] playerIdArray)
Parameters
Type | Name | Description |
---|---|---|
int[] | playerIdArray | The in-game ids of the clients to invoke the event on. |
InvokeClients(ulong[])
Server-only method to invoke the event on the specified clients.
Declaration
public void InvokeClients(ulong[] clientGuidArray)
Parameters
Type | Name | Description |
---|---|---|
ulong[] | clientGuidArray | The NGO guids of the clients to invoke the event on. |
InvokeOtherClients()
Client method to invoke the event on all other clients.
Declaration
public void InvokeOtherClients()
InvokeOtherClients(int[])
Client method to invoke the event on the specified clients.
Declaration
public void InvokeOtherClients(int[] playerIdArray)
Parameters
Type | Name | Description |
---|---|---|
int[] | playerIdArray | The in-game ids of the clients to invoke the event on. |
InvokeOtherClients(ulong[])
Client method to invoke the event on the specified clients.
Declaration
public void InvokeOtherClients(ulong[] clientGuidArray)
Parameters
Type | Name | Description |
---|---|---|
ulong[] | clientGuidArray | The NGO guids of the clients to invoke the event on. |
InvokeServer()
Client method to invoke the event on the server/host.
Declaration
public void InvokeServer()
Events
OnClientReceived
A callback that runs when the client receives an event.
Declaration
public event Action? OnClientReceived;
OnClientReceivedFromClient
A callback that runs when the client receives an event from another client.
Declaration
public event Action<ulong>? OnClientReceivedFromClient;
Type Parameters
Type | Description |
---|---|
ulong | The origin client ID. |
OnServerReceived
A callback that runs when the server receives an event.
Declaration
public event Action<ulong>? OnServerReceived;
Type Parameters
Type | Description |
---|---|
ulong | The origin client ID. |