@@ -162,14 +162,14 @@ public void SendCustomMessage(List<uint> clientIds, Stream stream, string channe
162
162
{
163
163
for ( int i = 0 ; i < ConnectedClientsList . Count ; i ++ )
164
164
{
165
- InternalMessageHandler . Send ( ConnectedClientsList [ i ] . ClientId , " MLAPI_CUSTOM_MESSAGE" , channel , stream ) ;
165
+ InternalMessageHandler . Send ( ConnectedClientsList [ i ] . ClientId , MLAPIConstants . MLAPI_CUSTOM_MESSAGE , channel , stream ) ;
166
166
}
167
167
}
168
168
else
169
169
{
170
170
for ( int i = 0 ; i < clientIds . Count ; i ++ )
171
171
{
172
- InternalMessageHandler . Send ( clientIds [ i ] , " MLAPI_CUSTOM_MESSAGE" , channel , stream ) ;
172
+ InternalMessageHandler . Send ( clientIds [ i ] , MLAPIConstants . MLAPI_CUSTOM_MESSAGE , channel , stream ) ;
173
173
}
174
174
}
175
175
}
@@ -182,7 +182,7 @@ public void SendCustomMessage(List<uint> clientIds, Stream stream, string channe
182
182
/// <param name="channel">The channel tos end the data on</param>
183
183
public void SendCustomMessage ( uint clientId , Stream stream , string channel = "MLAPI_DEFAULT_MESSAGE" )
184
184
{
185
- InternalMessageHandler . Send ( clientId , " MLAPI_CUSTOM_MESSAGE" , channel , stream ) ;
185
+ InternalMessageHandler . Send ( clientId , MLAPIConstants . MLAPI_CUSTOM_MESSAGE , channel , stream ) ;
186
186
}
187
187
188
188
@@ -281,9 +281,7 @@ private object Init(bool server)
281
281
diffieHellmanPublicKeys . Clear ( ) ;
282
282
#endif
283
283
MessageManager . channels . Clear ( ) ;
284
- MessageManager . messageTypes . Clear ( ) ;
285
284
MessageManager . reverseChannels . Clear ( ) ;
286
- MessageManager . reverseMessageTypes . Clear ( ) ;
287
285
SpawnManager . SpawnedObjects . Clear ( ) ;
288
286
SpawnManager . SpawnedObjectsList . Clear ( ) ;
289
287
SpawnManager . releasedNetworkObjectIds . Clear ( ) ;
@@ -404,24 +402,6 @@ private object Init(bool server)
404
402
MessageManager . reverseChannels . Add ( channelId , NetworkConfig . Channels [ i ] . Name ) ;
405
403
}
406
404
407
- //Add internal messagetypes directly
408
- MessageManager . messageTypes . Add ( "MLAPI_CONNECTION_REQUEST" , MLAPIConstants . MLAPI_CONNECTION_REQUEST ) ;
409
- MessageManager . messageTypes . Add ( "MLAPI_CONNECTION_APPROVED" , MLAPIConstants . MLAPI_CONNECTION_APPROVED ) ;
410
- MessageManager . messageTypes . Add ( "MLAPI_ADD_OBJECT" , MLAPIConstants . MLAPI_ADD_OBJECT ) ;
411
- MessageManager . messageTypes . Add ( "MLAPI_CLIENT_DISCONNECT" , MLAPIConstants . MLAPI_CLIENT_DISCONNECT ) ;
412
- MessageManager . messageTypes . Add ( "MLAPI_DESTROY_OBJECT" , MLAPIConstants . MLAPI_DESTROY_OBJECT ) ;
413
- MessageManager . messageTypes . Add ( "MLAPI_SWITCH_SCENE" , MLAPIConstants . MLAPI_SWITCH_SCENE ) ;
414
- MessageManager . messageTypes . Add ( "MLAPI_SPAWN_POOL_OBJECT" , MLAPIConstants . MLAPI_SPAWN_POOL_OBJECT ) ;
415
- MessageManager . messageTypes . Add ( "MLAPI_DESTROY_POOL_OBJECT" , MLAPIConstants . MLAPI_DESTROY_POOL_OBJECT ) ;
416
- MessageManager . messageTypes . Add ( "MLAPI_CHANGE_OWNER" , MLAPIConstants . MLAPI_CHANGE_OWNER ) ;
417
- MessageManager . messageTypes . Add ( "MLAPI_ADD_OBJECTS" , MLAPIConstants . MLAPI_ADD_OBJECTS ) ;
418
- MessageManager . messageTypes . Add ( "MLAPI_TIME_SYNC" , MLAPIConstants . MLAPI_TIME_SYNC ) ;
419
- MessageManager . messageTypes . Add ( "MLAPI_NETWORKED_VAR_DELTA" , MLAPIConstants . MLAPI_NETWORKED_VAR_DELTA ) ;
420
- MessageManager . messageTypes . Add ( "MLAPI_NETWORKED_VAR_UPDATE" , MLAPIConstants . MLAPI_NETWORKED_VAR_UPDATE ) ;
421
- MessageManager . messageTypes . Add ( "MLAPI_SERVER_RPC" , MLAPIConstants . MLAPI_SERVER_RPC ) ;
422
- MessageManager . messageTypes . Add ( "MLAPI_CLIENT_RPC" , MLAPIConstants . MLAPI_CLIENT_RPC ) ;
423
- MessageManager . messageTypes . Add ( "MLAPI_CUSTOM_MESSAGE" , MLAPIConstants . MLAPI_CUSTOM_MESSAGE ) ;
424
-
425
405
return settings ;
426
406
}
427
407
@@ -703,7 +683,7 @@ private void Update()
703
683
if ( NetworkConfig . ConnectionApproval )
704
684
writer . WriteByteArray ( NetworkConfig . ConnectionData ) ;
705
685
706
- InternalMessageHandler . Send ( clientId , " MLAPI_CONNECTION_REQUEST" , "MLAPI_INTERNAL" , stream , true ) ;
686
+ InternalMessageHandler . Send ( clientId , MLAPIConstants . MLAPI_CONNECTION_REQUEST , "MLAPI_INTERNAL" , stream , true ) ;
707
687
}
708
688
}
709
689
NetworkProfiler . EndEvent ( ) ;
@@ -789,7 +769,7 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId, int t
789
769
stream . SetLength ( totalSize ) ;
790
770
BitReader reader = new BitReader ( stream ) ;
791
771
792
- ushort messageType = reader . ReadUInt16Packed ( ) ;
772
+ byte messageType = reader . ReadByteDirect ( ) ;
793
773
794
774
uint headerByteSize = ( uint ) Arithmetic . VarIntSize ( messageType ) ;
795
775
NetworkProfiler . StartEvent ( TickType . Receive , ( uint ) ( totalSize - headerByteSize ) , channelId , messageType ) ;
@@ -911,7 +891,7 @@ internal void OnClientDisconnectFromServer(uint clientId)
911
891
{
912
892
BitWriter writer = new BitWriter ( stream ) ;
913
893
writer . WriteUInt32Packed ( clientId ) ;
914
- InternalMessageHandler . Send ( " MLAPI_CLIENT_DISCONNECT" , "MLAPI_INTERNAL" , clientId , stream ) ;
894
+ InternalMessageHandler . Send ( MLAPIConstants . MLAPI_CLIENT_DISCONNECT , "MLAPI_INTERNAL" , clientId , stream ) ;
915
895
}
916
896
}
917
897
}
@@ -926,7 +906,7 @@ private void SyncTime()
926
906
writer . WriteSinglePacked ( NetworkTime ) ;
927
907
int timestamp = NetworkConfig . NetworkTransport . GetNetworkTimestamp ( ) ;
928
908
writer . WriteInt32Packed ( timestamp ) ;
929
- InternalMessageHandler . Send ( " MLAPI_TIME_SYNC" , "MLAPI_TIME_SYNC" , stream ) ;
909
+ InternalMessageHandler . Send ( MLAPIConstants . MLAPI_TIME_SYNC , "MLAPI_TIME_SYNC" , stream ) ;
930
910
}
931
911
}
932
912
@@ -1035,7 +1015,7 @@ internal void HandleApproval(uint clientId, int prefabId, bool approved, Vector3
1035
1015
pair . Value . WriteNetworkedVarData ( stream , clientId ) ;
1036
1016
}
1037
1017
}
1038
- InternalMessageHandler . Send ( clientId , " MLAPI_CONNECTION_APPROVED" , "MLAPI_INTERNAL" , stream , true ) ;
1018
+ InternalMessageHandler . Send ( clientId , MLAPIConstants . MLAPI_CONNECTION_APPROVED , "MLAPI_INTERNAL" , stream , true ) ;
1039
1019
1040
1020
if ( OnClientConnectedCallback != null )
1041
1021
OnClientConnectedCallback . Invoke ( clientId ) ;
@@ -1075,7 +1055,7 @@ internal void HandleApproval(uint clientId, int prefabId, bool approved, Vector3
1075
1055
{
1076
1056
writer . WriteUInt32Packed ( clientId ) ;
1077
1057
}
1078
- InternalMessageHandler . Send ( clientPair . Key , " MLAPI_ADD_OBJECT" , "MLAPI_INTERNAL" , stream ) ;
1058
+ InternalMessageHandler . Send ( clientPair . Key , MLAPIConstants . MLAPI_ADD_OBJECT , "MLAPI_INTERNAL" , stream ) ;
1079
1059
}
1080
1060
}
1081
1061
}
0 commit comments