mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-09 15:08:13 +02:00
Pass the peer id to python for potentially async replies
This commit is contained in:
@@ -451,7 +451,7 @@ class Boss:
|
||||
tb = traceback.format_exc()
|
||||
self.show_error(_('remote_control mapping failed'), tb)
|
||||
|
||||
def peer_message_received(self, msg_bytes: bytes) -> Optional[bytes]:
|
||||
def peer_message_received(self, msg_bytes: bytes, peer_id: int) -> Optional[bytes]:
|
||||
cmd_prefix = b'\x1bP@kitty-cmd'
|
||||
terminator = b'\x1b\\'
|
||||
if msg_bytes.startswith(cmd_prefix) and msg_bytes.endswith(terminator):
|
||||
|
||||
@@ -418,13 +418,14 @@ parse_input(ChildMonitor *self) {
|
||||
Message *msg = msgs + i;
|
||||
PyObject *resp = NULL;
|
||||
if (msg->data) {
|
||||
resp = PyObject_CallMethod(global_state.boss, "peer_message_received", "y#", msg->data, (int)msg->sz);
|
||||
resp = PyObject_CallMethod(global_state.boss, "peer_message_received", "y#K", msg->data, (int)msg->sz, msg->peer_id);
|
||||
free(msg->data);
|
||||
if (!resp) PyErr_Print();
|
||||
}
|
||||
if (resp && PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
||||
else send_response(msg->peer_id, NULL, 0);
|
||||
Py_CLEAR(resp);
|
||||
if (resp) {
|
||||
if (PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
||||
Py_CLEAR(resp);
|
||||
} else send_response(msg->peer_id, NULL, 0);
|
||||
}
|
||||
free(msgs); msgs = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user