timotejroiko / net-ipc

A simple node.js IPC client-server with no dependencies
MIT License
29 stars 6 forks source link

Client connection send and recv , not a nodejs client #8

Open jhay06 opened 6 months ago

jhay06 commented 6 months ago

Hi , as the title says, i have an App i want to have nodejs serve the IPC server and Qt c++ as a client app , but how can i send data to ipc server ? is it a json ? if yes what is the signature /format of this json data to make net-ipc accept the sent data from client ?

timotejroiko commented 6 months ago

hey, the library uses a small header followed by either json or messagepack, optionally compressed by deflate, depending on the configuration.

connection starts at connection.js#_init() where the first 3 bytes of the payload are checked, if its "GET" treat as a websocket upgrade request, if its "IPC" accept the connection directly.

subsequent messages are tagged with a leading varint (variable-length integer) specifying message size, followed by the message itself. check interfaces.js#_write()

after decompression and decoding, the message itself has the following format:

{
    t: number, // message type
    d: any // message content
}