Files
MaaAssistantArknights/docs/en-us/protocol/callback-schema.md
2026-07-07 00:30:53 +08:00

16 KiB

order, icon
order icon
2 material-symbols:u-turn-left

Callback Message Protocol

::: info Note Callback messages are rapidly evolving with each version update, so this document may become outdated. For the latest information, please refer to the C# Integration Source Code :::

Callback Function Prototype

typedef void(ASST_CALL* AsstCallback)(int msg, const char* details, void* custom_arg);

Parameter Overview

  • int msg
    Message type

    enum class AsstMsg
    {
        /* Global Info */
        InternalError     = 0,           // Internal error
        InitFailed        = 1,           // Initialization failed
        ConnectionInfo    = 2,           // Connection-related information
        AllTasksCompleted = 3,           // All tasks completed
        AsyncCallInfo     = 4,           // External asynchronous call information
        Destroyed         = 5,           // Instance destroyed
    
        /* TaskChain Info */
        TaskChainError     = 10000,      // Task chain execution/recognition error
        TaskChainStart     = 10001,      // Task chain started
        TaskChainCompleted = 10002,      // Task chain completed
        TaskChainExtraInfo = 10003,      // Task chain extra information
        TaskChainStopped   = 10004,      // Task chain manually stopped
    
        /* SubTask Info */
        SubTaskError      = 20000,       // Atomic task execution/recognition error
        SubTaskStart      = 20001,       // Atomic task started
        SubTaskCompleted  = 20002,       // Atomic task completed
        SubTaskExtraInfo  = 20003,       // Atomic task extra information
        SubTaskStopped    = 20004,       // Atomic task manually stopped
    
        /* Web Request */
        ReportRequest     = 30000,       // Report request
    };
    
  • const char* details
    Message details, JSON string, see Field Explanations

  • void* custom_arg
    Custom parameter from the caller, returns the custom_arg parameter from the AsstCreateEx interface unchanged. C-like languages can use this parameter to pass this pointers

Field Explanations

InternalError

Todo

InitFailed

{
    "what": string,     // Error type
    "why": string,      // Error reason
    "details": object   // Error details
}

ConnectionInfo

{
    "what": string,     // Information type
    "why": string,      // Information reason
    "uuid": string,     // Device unique ID (empty when connection fails)
    "details": {
        "adb": string,     // AsstConnect interface adb_path parameter
        "address": string, // AsstConnect interface address parameter
        "config": string   // AsstConnect interface config parameter
    }
}

Common What Field Values

  • ConnectFailed
    Connection failed

  • Connected
    Connected, note that the uuid field is empty at this point (next step will retrieve it)

  • UuidGot
    Device unique ID retrieved

  • UnsupportedResolution
    Resolution not supported

  • ResolutionError
    Resolution retrieval error

  • Reconnecting
    Connection lost (adb/emulator crashed), attempting reconnection

  • Reconnected
    Connection lost (adb/emulator crashed), reconnection successful

  • Disconnect
    Connection lost (adb/emulator crashed), and reconnection failed

  • ScreencapFailed
    Screenshot failed (adb/emulator crashed), and retry failed

  • TouchModeNotAvailable
    Unsupported touch mode

  • ResolutionGot
    Resolution retrieved

  • FastestWayToScreencap
    Fastest screenshot method found, details structure:

    • method (string, required): Fastest screenshot method.
    • cost (number, required): Time cost in milliseconds.
    • alternatives (array