@@ -503,7 +503,7 @@ protected async void ParseMessage(byte[] bytes)
503
503
{
504
504
Patch ( bytes , 1 ) ;
505
505
}
506
- else if ( code == ColyseusProtocol . ROOM_DATA )
506
+ else if ( code == ColyseusProtocol . ROOM_DATA || ColyseusProtocol . ROOM_DATA_BYTES )
507
507
{
508
508
IColyseusMessageHandler handler = null ;
509
509
object type ;
@@ -523,14 +523,24 @@ protected async void ParseMessage(byte[] bytes)
523
523
524
524
if ( handler != null )
525
525
{
526
- //
527
- // MsgPack deserialization can be optimized:
528
- // https://github.com/deniszykov/msgpack-unity3d/issues/23
529
- //
530
- object message = bytes . Length > it . Offset
531
- ? MsgPack . Deserialize ( handler . Type ,
532
- new MemoryStream ( bytes , it . Offset , bytes . Length - it . Offset , false ) )
533
- : null ;
526
+ object message = null ;
527
+
528
+ if ( code == ColyseusProtocol . ROOM_DATA )
529
+ {
530
+ //
531
+ // MsgPack deserialization can be optimized:
532
+ // https://github.com/deniszykov/msgpack-unity3d/issues/23
533
+ //
534
+ message = bytes . Length > it . Offset
535
+ ? MsgPack . Deserialize ( handler . Type ,
536
+ new MemoryStream ( bytes , it . Offset , bytes . Length - it . Offset , false ) )
537
+ : null ;
538
+ }
539
+ else if ( code == ColyseusProtocol . ROOM_DATA_BYTES )
540
+ {
541
+ message = new byte [ bytes . Length - it . Offset ] ;
542
+ Buffer . BlockCopy ( bytes , it . Offset , ( byte [ ] ) message , 0 , bytes . Length - it . Offset ) ;
543
+ }
534
544
535
545
handler . Invoke ( message ) ;
536
546
}
0 commit comments