onReceiveNewMessage static method

void onReceiveNewMessage(
  1. V2TimMessage? v2timMessage
)

群消息和c2c消息

Implementation

static void onReceiveNewMessage(V2TimMessage? v2timMessage) {
  if (v2timMessage != null) {
    //groupID 为空的时候表示c2c消息
    if (isEmpty(v2timMessage.groupID)) {
      IV2MsgModel? iv2msgModel;
      for (var element in c2cMsgParsers) {
        iv2msgModel = element.parser(v2timMessage);
        if (iv2msgModel != null) {
          continue;
        }
      }
      for (var element in listC2CMsgListener) {
        if (iv2msgModel != null) {
          element.onReceiveNewMessage(iv2msgModel);
        }
      }
    } else {
      //群消息
      IGroupMsgModel? iGroupMsgModel;
      for (var value in groupImParsers) {
        iGroupMsgModel = value.parserGroup(v2timMessage);
        if (iGroupMsgModel != null) {
          continue;
        }
      }
      for (var value1 in listGroupMsgListener) {
        if (iGroupMsgModel != null) {
          value1.onReceiveNewMessage(iGroupMsgModel);
        }
      }
    }
  }
}