Skip to content

Latest commit

 

History

History
188 lines (154 loc) · 2.24 KB

PROTOCOL.md

File metadata and controls

188 lines (154 loc) · 2.24 KB

IPC Protocol

This file describes the IPC protocol used for the PHP <-> Lazarus communication.

This protocol is based on JSON RPC.

Each message needs to be terminated by NULL character (PHP = "\0", Lazarus = #0). This will be used to identify each message on the stream.

Request (Command):

{
    "id": 2,
    "method": "createObject",
    "params": [
        {
            "lazarusClass": "TButton",
            "lazarusObjectId": 1,
            "parent": 0
        }
    ]
}

Response:

{
    "id": 2,
    "result": 123
}

Notification (Event):

{
    "method": "eventCallback",
    "params": [
        {
            "name": "Click",
            "target": 123
        }
    ]
}

Commands available:

createObject

Request:

{
    "id": 2,
    "method": "createObject",
    "params": [
        {
            "lazarusClass": "TButton",
            "lazarusObjectId": 123,
            "parent": 0
        }
    ]
}

Response:

{
    "id": 2,
    "result": 123 // This is the object ID
}

setObjectProperty

{
    "id": 2,
    "method": "setObjectProperty",
    "params": [
        lazarusObjectId,
        "propertyName",
        "propertyValue"
    ]
}

Response:

{
    "id": 2,
    "result": true
}

setObjectEventListener

{
    "id": 2,
    "method": "setObjectEventListener",
    "params": [
        lazarusObjectId,
        "eventName"
    ]
}

Response:

{
    "id": 2,
    "result": true
}

getObjectProperty

{
    "callback":false,
    "id":134,
    "method":"getObjectProperty",
    "params":[
        14,
        "itemIndex"
    ]
}

Response:

{
    "id": 134,
    "result": 1
}

callObjectMethod

{
    "callback":{},
    "id":19,
    "method":"callObjectMethod",
    "params":[
        14,
        "items.addObject",
        [
            "Male",
            0
        ]
    ]
}

Response:

{
    "id": 19,
    "result": 14
}

Debug

if you want debug something from lazarus you can use the key "debug" like

{
    "callback" : {},
    "id" : 94,
    "method" : "setObjectProperty",
    "params" : [
        18,
        "caption",
        "test"
    ],
    "debug" : true
}