File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
packages/networker/networker/lib/src/plugin Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import 'dart:typed_data';
33import 'package:networker/networker.dart' ;
44
55class InternalChannelPipe extends RawNetworkerPipe {
6- InternalChannelPipe ();
6+ final int bytes;
7+ final int ? channel;
8+
9+ InternalChannelPipe ({this .bytes = 1 , this .channel});
710
811 static NetworkerPipe <Uint8List , Uint8List > reversed () {
912 return ReversedNetworkerPipe (InternalChannelPipe ());
@@ -14,17 +17,19 @@ class InternalChannelPipe extends RawNetworkerPipe {
1417 if (data.isEmpty) {
1518 return (data, channel);
1619 }
17- final rawChannel = data.first ;
18- final rawData = data.sublist (1 );
20+ final rawChannel = data.sublist ( 0 , bytes).buffer. asByteData (). getUint8 ( 0 ) ;
21+ final rawData = data.sublist (bytes );
1922 return (rawData, rawChannel);
2023 }
2124
2225 @override
2326 (Uint8List , Channel ) encodeChannel (Uint8List data, Channel channel) {
2427 final builder = BytesBuilder ();
25- builder.addByte (channel);
28+ for (int i = bytes - 1 ; i >= 0 ; i-- ) {
29+ builder.addByte (channel >> (i * 8 ) & 0xFF );
30+ }
2631 builder.add (data);
27- return (builder.toBytes (), channel);
32+ return (builder.toBytes (), this .channel ?? channel);
2833 }
2934}
3035
You can’t perform that action at this time.
0 commit comments