Base NetworkConnection class for server-to-client and client-to-server connection.
More...
|
readonly int | connectionId |
| Unique identifier for this connection that is assigned by the transport layer. More...
|
|
bool | isAuthenticated |
| Flag that indicates the client has been authenticated. More...
|
|
object | authenticationData |
| General purpose object to hold authentication data, character selection, tokens, etc. More...
|
|
bool | isReady |
| A server connection is ready after joining the game world. More...
|
|
float | lastMessageTime |
| Last time a message was received for this connection. Includes system and user messages. More...
|
|
|
Batcher | GetBatchForChannelId (int channelId) |
|
abstract void | SendToTransport (ArraySegment< byte > segment, int channelId=Channels.Reliable) |
|
Base NetworkConnection class for server-to-client and client-to-server connection.
Definition at line 9 of file NetworkConnection.cs.
◆ Disconnect()
abstract void Mirror.NetworkConnection.Disconnect |
( |
| ) |
|
|
pure virtual |
◆ GetBatchForChannelId()
Batcher Mirror.NetworkConnection.GetBatchForChannelId |
( |
int |
channelId | ) |
|
|
protected |
Definition at line 87 of file NetworkConnection.cs.
88 {
89
90 Batcher batch;
91 if (!batches.TryGetValue(channelId, out batch))
92 {
93
94 int threshold = Transport.activeTransport.GetBatchThreshold(channelId);
95
96
97 batch = new Batcher(threshold);
98 batches[channelId] = batch;
99 }
100 return batch;
101 }
◆ Send< T >()
void Mirror.NetworkConnection.Send< T > |
( |
T |
message, |
|
|
int |
channelId = Channels.Reliable |
|
) |
| |
Send a NetworkMessage to this connection over the given channel.
- Type Constraints
-
T | : | struct | |
T | : | NetworkMessage | |
Definition at line 131 of file NetworkConnection.cs.
132 : struct, NetworkMessage
133 {
134 using (NetworkWriterPooled writer = NetworkWriterPool.Get())
135 {
136
137 MessagePacking.Pack(message, writer);
138 NetworkDiagnostics.OnSend(message, channelId, writer.Position, 1);
139 Send(writer.ToArraySegment(), channelId);
140 }
141 }
◆ ValidatePacketSize()
static bool Mirror.NetworkConnection.ValidatePacketSize |
( |
ArraySegment< byte > |
segment, |
|
|
int |
channelId |
|
) |
| |
|
staticprotected |
Definition at line 108 of file NetworkConnection.cs.
109 {
110 int max = Transport.activeTransport.GetMaxPacketSize(channelId);
111 if (segment.Count > max)
112 {
113 Debug.LogError($"NetworkConnection.ValidatePacketSize: cannot send packet larger than {max} bytes, was {segment.Count} bytes");
114 return false;
115 }
116
117 if (segment.Count == 0)
118 {
119
120 Debug.LogError("NetworkConnection.ValidatePacketSize: cannot send zero bytes");
121 return false;
122 }
123
124
125 return true;
126 }
◆ authenticationData
object Mirror.NetworkConnection.authenticationData |
General purpose object to hold authentication data, character selection, tokens, etc.
Definition at line 27 of file NetworkConnection.cs.
◆ batches
Dictionary<int, Batcher> Mirror.NetworkConnection.batches = new Dictionary<int, Batcher>() |
|
protected |
◆ connectionId
readonly int Mirror.NetworkConnection.connectionId |
Unique identifier for this connection that is assigned by the transport layer.
Definition at line 21 of file NetworkConnection.cs.
◆ isAuthenticated
bool Mirror.NetworkConnection.isAuthenticated |
◆ isReady
bool Mirror.NetworkConnection.isReady |
A server connection is ready after joining the game world.
Definition at line 33 of file NetworkConnection.cs.
◆ lastMessageTime
float Mirror.NetworkConnection.lastMessageTime |
Last time a message was received for this connection. Includes system and user messages.
Definition at line 39 of file NetworkConnection.cs.
◆ LocalConnectionId
const int Mirror.NetworkConnection.LocalConnectionId = 0 |
|
static |
◆ address
abstract string Mirror.NetworkConnection.address |
|
get |
IP address of the connection. Can be useful for game master IP bans etc.
Definition at line 36 of file NetworkConnection.cs.
◆ clientOwnedObjects
All NetworkIdentities owned by this connection. Can be main player, pets, etc.
Definition at line 51 of file NetworkConnection.cs.
◆ identity
This connection's main object (usually the player object).
Definition at line 42 of file NetworkConnection.cs.
◆ observing
◆ remoteTimeStamp
double Mirror.NetworkConnection.remoteTimeStamp |
|
getset |
last batch's remote timestamp. not interpolated. useful for NetworkTransform etc.
Definition at line 71 of file NetworkConnection.cs.