parse static method

IPDEvent parse(
  1. dynamic message
)

解析事件

Implementation

static IPDEvent parse(dynamic message) {
  IPDEventType type = IPDEventType.unknown;
  IPDEventAction action = IPDEventAction.unknown;
  int code = 0;
  String? msg;
  String? extra;
  int id = 0;

  Map<String, dynamic>? ret = (message as Map<String, dynamic>?);
  if (ret != null) {
    // type = (ret["type"] as int).toEventType;
    type = IPDEventType.parse(ret["type"] as int);
    id = ret["viewId"] ?? 0;
    // action = (ret["action"] as String).toEventAction;
    action = IPDEventAction.parse((ret["action"] as String));
    code = ret["code"] ?? 0;
    msg = ret["msg"];
    extra = ret["extra"];
  }
  return IPDEvent(type, action,
      code: code, msg: msg, extra: extra, viewId: id);
}