mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 01:38:02 +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()
|
tb = traceback.format_exc()
|
||||||
self.show_error(_('remote_control mapping failed'), tb)
|
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'
|
cmd_prefix = b'\x1bP@kitty-cmd'
|
||||||
terminator = b'\x1b\\'
|
terminator = b'\x1b\\'
|
||||||
if msg_bytes.startswith(cmd_prefix) and msg_bytes.endswith(terminator):
|
if msg_bytes.startswith(cmd_prefix) and msg_bytes.endswith(terminator):
|
||||||
|
|||||||
@@ -418,13 +418,14 @@ parse_input(ChildMonitor *self) {
|
|||||||
Message *msg = msgs + i;
|
Message *msg = msgs + i;
|
||||||
PyObject *resp = NULL;
|
PyObject *resp = NULL;
|
||||||
if (msg->data) {
|
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);
|
free(msg->data);
|
||||||
if (!resp) PyErr_Print();
|
if (!resp) PyErr_Print();
|
||||||
}
|
}
|
||||||
if (resp && PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
if (resp) {
|
||||||
else send_response(msg->peer_id, NULL, 0);
|
if (PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
||||||
Py_CLEAR(resp);
|
Py_CLEAR(resp);
|
||||||
|
} else send_response(msg->peer_id, NULL, 0);
|
||||||
}
|
}
|
||||||
free(msgs); msgs = NULL;
|
free(msgs); msgs = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user