Struct INetwork
This type represents a pointer to an unmanaged open.mp INetwork interface.
[OpenMpApi(new Type[] { typeof(IExtensible) })]
public readonly struct INetwork : IEquatable<INetwork>, INetwork.IManagedInterface, IExtensible.IManagedInterface, IUnmanagedInterface
- Implements
- Inherited Members
Constructors
INetwork(nint)
Initializes a new instance of the INetwork struct.
public INetwork(nint handle)
Parameters
handlenintA pointer to the unmanaged interface.
Properties
Handle
Gets the handle to the unmanaged interface instance.
public nint Handle { get; }
Property Value
HasValue
Gets a value indicating whether the pointer has a value.
public bool HasValue { get; }
Property Value
Methods
AddExtension<T>(T)
Adds the specified managed extension to this extensible.
public void AddExtension<T>(T extension) where T : Extension
Parameters
extensionTAn instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.
Type Parameters
TThe type of the managed extension.
Remarks
A managed extension can only be added to one extensible.
Exceptions
- ArgumentException
Throw when an instance of the extension type was already added to this extensible.
Ban(BanEntry, TimeSpan)
Bans a peer from the network.
public void Ban(BanEntry entry, TimeSpan expire)
Parameters
entryBanEntryThe ban entry containing details about the ban.
expireTimeSpanThe duration of the ban before it expires.
BroadcastPacket(SpanLite<byte>, int, IPlayer, bool)
Broadcasts a packet to all peers on this network.
public bool BroadcastPacket(SpanLite<byte> data, int channel, IPlayer exceptPeer = default, bool dispatchEvents = true)
Parameters
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use for broadcasting the packet.
exceptPeerIPlayerThe peer to exclude from the broadcast.
dispatchEventsboolWhether to dispatch packet-related events.
Returns
- bool
trueif the packet was broadcast successfully; otherwise,false.
BroadcastRPC(int, SpanLite<byte>, int, IPlayer, bool)
Broadcasts an RPC to all peers on this network.
public bool BroadcastRPC(int id, SpanLite<byte> data, int channel, IPlayer exceptPeer = default, bool dispatchEvents = true)
Parameters
idintThe RPC ID for the current network.
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use for broadcasting the RPC.
exceptPeerIPlayerThe peer to exclude from the broadcast.
dispatchEventsboolWhether to dispatch RPC-related events.
Returns
- bool
trueif the RPC was broadcast successfully; otherwise,false.
Disconnect(IPlayer)
Disconnects a peer from the network.
public void Disconnect(IPlayer peer)
Parameters
peerIPlayerThe network peer to disconnect.
Equals(INetwork)
public bool Equals(INetwork other)
Parameters
otherINetwork
Returns
Equals(object?)
public override bool Equals(object? other)
Parameters
otherobject
Returns
GetEventDispatcher()
Gets the dispatcher which dispatches network events.
public IEventDispatcher<INetworkEventHandler> GetEventDispatcher()
Returns
- IEventDispatcher<INetworkEventHandler>
An event dispatcher for network events.
GetExtension(UID)
Gets the extension with the specified id.
public IExtension GetExtension(UID id)
Parameters
idUIDThe identifier of the extension type.
Returns
- IExtension
The extension or null if the extension could not be found.
GetExtension<T>()
Gets the specified managed extension from this extensible.
public T GetExtension<T>() where T : Extension
Returns
- T
An instance of the extension with type
T.
Type Parameters
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
GetHashCode()
public override int GetHashCode()
Returns
GetInEventDispatcher()
Gets the dispatcher which dispatches incoming network events.
public IEventDispatcher<INetworkInEventHandler> GetInEventDispatcher()
Returns
- IEventDispatcher<INetworkInEventHandler>
An event dispatcher for incoming network events.
GetNetworkType()
Gets the network type of the network.
public ENetworkType GetNetworkType()
Returns
- ENetworkType
The network type of the network.
GetOutEventDispatcher()
Gets the dispatcher which dispatches outgoing network events.
public IEventDispatcher<INetworkOutEventHandler> GetOutEventDispatcher()
Returns
- IEventDispatcher<INetworkOutEventHandler>
An event dispatcher for outgoing network events.
GetPerPacketInEventDispatcher()
Gets the dispatcher which dispatches incoming network events bound to a specific packet ID.
public IIndexedEventDispatcher<ISingleNetworkInEventHandler> GetPerPacketInEventDispatcher()
Returns
- IIndexedEventDispatcher<ISingleNetworkInEventHandler>
An indexed event dispatcher for incoming packet events.
GetPerPacketOutEventDispatcher()
Gets the dispatcher which dispatches outgoing network events bound to a specific packet ID.
public IIndexedEventDispatcher<ISingleNetworkOutEventHandler> GetPerPacketOutEventDispatcher()
Returns
- IIndexedEventDispatcher<ISingleNetworkOutEventHandler>
An indexed event dispatcher for outgoing packet events.
GetPerRPCInEventDispatcher()
Gets the dispatcher which dispatches incoming network events bound to a specific RPC ID.
public IIndexedEventDispatcher<ISingleNetworkInEventHandler> GetPerRPCInEventDispatcher()
Returns
- IIndexedEventDispatcher<ISingleNetworkInEventHandler>
An indexed event dispatcher for incoming RPC events.
GetPerRPCOutEventDispatcher()
Gets the dispatcher which dispatches outgoing network events bound to a specific RPC ID.
public IIndexedEventDispatcher<ISingleNetworkOutEventHandler> GetPerRPCOutEventDispatcher()
Returns
- IIndexedEventDispatcher<ISingleNetworkOutEventHandler>
An indexed event dispatcher for outgoing RPC events.
GetPing(IPlayer)
Gets the last ping for a peer on this network.
public uint GetPing(IPlayer peer)
Parameters
peerIPlayerThe network peer to get the ping for.
Returns
- uint
The last ping value, or 0 if the peer is not on this network.
GetStatistics(IPlayer)
Gets network statistics for a specific player or the entire network.
public NetworkStats GetStatistics(IPlayer player = default)
Parameters
playerIPlayerThe player to get statistics for, or
defaultfor the entire network.
Returns
- NetworkStats
The network statistics.
QueryExtension<T>()
Gets the specified unmanaged extension from this extensible.
public T QueryExtension<T>() where T : unmanaged, IExtension.IManagedInterface
Returns
- T
The unmanaged extension or null if the extension could not be found.
Type Parameters
TThe type of the unmanaged extension.
RemoveExtension(IExtension)
Removes the specified extension from this extensible.
public void RemoveExtension(IExtension extension)
Parameters
extensionIExtensionThe extension to remove.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
RemoveExtension(UID)
Removes the extension with the specified id from this extensible.
public void RemoveExtension(UID id)
Parameters
idUIDThe identifier of the extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
RemoveExtension<T>(T)
Removes the specified managed extension from this extensible.
public void RemoveExtension<T>(T extension) where T : Extension
Parameters
extensionTThe managed extension to remove.
Type Parameters
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
SendPacket(IPlayer, SpanLite<byte>, int, bool)
Sends a packet to a network peer.
public bool SendPacket(IPlayer peer, SpanLite<byte> data, int channel, bool dispatchEvents = true)
Parameters
peerIPlayerThe network peer to send the packet to.
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use for sending the packet.
dispatchEventsboolWhether to dispatch packet-related events.
Returns
- bool
trueif the packet was sent successfully; otherwise,false.
SendRPC(IPlayer, int, SpanLite<byte>, int, bool)
Sends an RPC to a network peer.
public bool SendRPC(IPlayer peer, int id, SpanLite<byte> data, int channel, bool dispatchEvents = true)
Parameters
peerIPlayerThe network peer to send the RPC to.
idintThe RPC ID for the current network.
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use for sending the RPC.
dispatchEventsboolWhether to dispatch RPC-related events.
Returns
- bool
trueif the RPC was sent successfully; otherwise,false.
TryGetExtension<T>()
Tries to get the specified managed extension from this extensible.
public T? TryGetExtension<T>() where T : Extension
Returns
- T
An instance of the extension with type
Tor null if no extension with the specified type could be found.
Type Parameters
TThe type of the managed extension.
TryQueryExtension<T>(out T)
Tries to get the specified unmanaged extension from this extensible.
public bool TryQueryExtension<T>(out T extension) where T : unmanaged, IExtension.IManagedInterface
Parameters
extensionTThe extension if found, otherwise null.
Returns
Type Parameters
TThe type of the unmanaged extension.
Unban(BanEntry)
Unbans a peer from the network.
public void Unban(BanEntry entry)
Parameters
entryBanEntryThe ban entry to remove.
Update()
Updates server parameters.
public void Update()
Operators
operator ==(INetwork, object?)
Determines whether the specified values are equal.
public static bool operator ==(INetwork lhs, object? rhs)
Parameters
lhsINetworkThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are equal; otherwise,false.
explicit operator INetwork(IExtensible)
Casts the IExtensible to a INetwork.
public static explicit operator INetwork(IExtensible value)
Parameters
valueIExtensibleThe IExtensible to cast.
Returns
explicit operator IExtensible(INetwork)
Casts the INetwork to a IExtensible.
public static explicit operator IExtensible(INetwork value)
Parameters
Returns
- IExtensible
The converted IExtensible.
operator !=(INetwork, object?)
Determines whether the specified values are not equal.
public static bool operator !=(INetwork lhs, object? rhs)
Parameters
lhsINetworkThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are not equal; otherwise,false.