handleMessage method

void handleMessage(
  1. Header header,
  2. InputStream body
)
override

Implementation

void handleMessage(Header header, InputStream body) {
  super.handleMessage(header, body);
  switch (header.type) {
    case MessageType.request:
      late ReplyStatus status;
      final requestId = body.readInt();
      final idstr = body.readString();
      final Identity identity = stringToIdentity(idstr);

      // For compatibility with the old FacetPath.
      final facetPath = body.readStringList();
      final facet = facetPath.isNotEmpty ? facetPath[0] : '';

      final operation = body.readString();
      final mode = body.readByte();
      final operationMode = OperationMode.values[mode];

      final context = body.readContext();
      final encap = body.readEncapsulation();

      final o = getObject(identity, facet);

      final Current current = Current(
        adapter: adapter,
        con: this,
        id: identity,
        facet: facet,
        operation: operation,
        mode: operationMode,
        ctx: context,
        requestId: requestId,
        encoding: encap.encoding,
      );
      final message = reply(header, current);

      Incoming incoming = Incoming(message, body, current);

      if (o == null) {
        status = ReplyStatus.replyObjectNotExist;
      } else {
        bool handled = o.iceDispatch(incoming, current);
        if (!handled) {
          status = ReplyStatus.replyOperationNotExist;
        }
      }

      if (incoming.reply == null) {
        incoming.createReply((output) {}, status);
      }

      sendReply(incoming.reply!);
      break;
    case MessageType.closeConnection:
      socket.close();
      break;
    default:
      break;
  }
}