In the public channel, when the client successfully connects to the ZkLink node, the server will return a message with ID 0, which contains the listen_key automatically created by the server for the connection:
The server will send ping frame to the client every two minutes, and the client should reply the pong frame within 10 minutes, otherwise the connection will be automatically disconnected.
Public Topics
Topic of transaction execution results: txExecuteResult@{sub_account_id}, for example when sub_account_id is 1, the topic will be txExecuteResult@1;
full exit event: fullExitEvent@{sub_account_id}, for example when sub_account_id is 1, the topic will be fullExitEvent@1.
Subscribe & Unsubscribe Topics
The client can subscribe and unsubscribe to topics at any time after connecting, and only needs to send a request to the service:
where the value of method can be subscribe or unSubscribe. The id in the response content is an unsigned integer, which serves as the unique identifier of the communication. It also contains the value of the currently subscribed topic list.
The client can use the listen_key(returned when the Websocket first connection) to query the topic list of its corresponding Websocket connection. The return value is:
["txExecuteResult@1","fullExitEvent@1"]
When the Websocket connection corresponding to listen_key is disconnected, null is returned.