Skip to main content

KcpTransport

A class in Alta.NetworkTransport.Runtime, Alta.NetworkingTransport.Kcp.

The KCP (reliable UDP) network transport the game uses by default. NetworkManager creates it from KcpSettings; both sides use it to open servers and client connections.

Constructors​

MemberWhat it is
KcpTransport(KcpSettings settings)Creates a KcpTransport from settings.

Fields​

4 private and internal fields
MemberWhat it is
private int channelCountNumber of channels created so far; the next channel ID.
private readonly bool[] channelReliabilityWhether each channel ID (up to 256) is reliable.
private static readonly Logger LoggerNLog logger that the KCP library's info, warning and error logs are routed to (warnings log as errors).
private readonly KcpSettings settingsThe KCP settings passed to every server and client this transport creates.

Properties​

MemberWhat it is
int ByteOffset { get; }Bytes reserved at the start of each packet buffer before game data; 1 for KCP.
int PacketSize { get; }Maximum packet size in bytes (1200).

Events​

MemberWhat it is
event Action<AltaNetworkError> OnErrorRaised when the transport reports a network error.

Methods​

MemberWhat it is
ITransportClient Connect(string ipAddress, int port)Client: starts a KCP connection to the given address and port and returns the client wrapper.
int CreateChannel(bool isReliable)Registers the next channel ID as reliable or unreliable and returns that ID.
ITransportServer CreateServer(int port)Server: starts a KCP server on the given port and returns the server wrapper.
void Terminate()Does nothing for KCP.
KcpChannel ToKcpChannel(int channelId)Maps a channel ID to KCP's reliable or unreliable channel, as set by CreateChannel.
1 private and internal method
MemberWhat it is
private void FixNonAlloc()Forces the KCP settings to non-allocating mode; called from the constructor.

Used in​

Members of other types that take, return or hold a KcpTransport: