Get async response working with sockets
This commit is contained in:
parent
34a7b42063
commit
5ba92d06cf
@ -516,11 +516,10 @@ class Boss:
|
|||||||
if window is not None and response is not None and not isinstance(response, AsyncResponse):
|
if window is not None and response is not None and not isinstance(response, AsyncResponse):
|
||||||
window.send_cmd_response(response)
|
window.send_cmd_response(response)
|
||||||
if peer_id > 0:
|
if peer_id > 0:
|
||||||
if response is None or isinstance(response, AsyncResponse):
|
if response is None:
|
||||||
data = b''
|
send_data_to_peer(peer_id, b'')
|
||||||
else:
|
elif not isinstance(response, AsyncResponse):
|
||||||
data = encode_response_for_peer(response)
|
send_data_to_peer(peer_id, encode_response_for_peer(response))
|
||||||
send_data_to_peer(peer_id, data)
|
|
||||||
|
|
||||||
def _execute_remote_command(self, pcmd: Dict[str, Any], window: Optional[Window] = None, peer_id: int = 0) -> RCResponse:
|
def _execute_remote_command(self, pcmd: Dict[str, Any], window: Optional[Window] = None, peer_id: int = 0) -> RCResponse:
|
||||||
from .remote_control import handle_cmd
|
from .remote_control import handle_cmd
|
||||||
|
|||||||
@ -442,7 +442,7 @@ parse_input(ChildMonitor *self) {
|
|||||||
}
|
}
|
||||||
if (resp) {
|
if (resp) {
|
||||||
if (PyBytes_Check(resp)) send_response_to_peer(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
if (PyBytes_Check(resp)) send_response_to_peer(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp));
|
||||||
else if (resp == Py_None || resp == Py_True) send_response_to_peer(msg->peer_id, NULL, 0);
|
else if (resp == Py_None) send_response_to_peer(msg->peer_id, NULL, 0);
|
||||||
Py_CLEAR(resp);
|
Py_CLEAR(resp);
|
||||||
} else send_response_to_peer(msg->peer_id, NULL, 0);
|
} else send_response_to_peer(msg->peer_id, NULL, 0);
|
||||||
}
|
}
|
||||||
@ -1732,8 +1732,10 @@ send_response_to_peer(id_type peer_id, const char *msg, size_t msg_sz) {
|
|||||||
peer->write.capacity += msg_sz;
|
peer->write.capacity += msg_sz;
|
||||||
} else fatal("Out of memory");
|
} else fatal("Out of memory");
|
||||||
}
|
}
|
||||||
if (msg) memcpy(peer->write.data + peer->write.used, msg, msg_sz);
|
if (msg_sz && msg) {
|
||||||
peer->write.used += msg_sz;
|
memcpy(peer->write.data + peer->write.used, msg, msg_sz);
|
||||||
|
peer->write.used += msg_sz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wakeup = true;
|
wakeup = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user