send method
send message through the channel
Implementation
@override
Future<Object?> send(MethodCall msg) async {
while (_socket == null) {
await Future.delayed(const Duration(milliseconds: 100));
}
List<int> msgBuffer = [];
Uint8List id = _genID();
msgBuffer.addAll(id);
msgBuffer.add(0);
msgBuffer.addAll(decodeInput(msg));
msgBuffer.addAll([0, 0, 0]);
_socket!.add(msgBuffer);
_Message reply = await _replyMessages
.where((event) => event.id == _bytesToInt(id))
.first;
if (reply.data.isNotEmpty) {
switch (reply.data.first) {
case 1:
throw encodeException(reply.data);
default:
if (reply.data.isNotEmpty) {
return encodeOutput(reply.data);
}
}
}
}