mirror of
https://github.com/godotengine/godot.git
synced 2025-10-21 08:53:35 +00:00
Allow LSP to process multiple messages per poll
This commit is contained in:
parent
aef11a1427
commit
e2485044a1
4 changed files with 25 additions and 13 deletions
|
@ -105,7 +105,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
|
|||
|
||||
Error GDScriptLanguageProtocol::LSPeer::send_data() {
|
||||
int sent = 0;
|
||||
if (!res_queue.is_empty()) {
|
||||
while (!res_queue.is_empty()) {
|
||||
CharString c_res = res_queue[0];
|
||||
if (res_sent < c_res.size()) {
|
||||
Error err = connection->put_partial_data((const uint8_t *)c_res.get_data() + res_sent, c_res.size() - res_sent - 1, sent);
|
||||
|
@ -229,7 +229,9 @@ void GDScriptLanguageProtocol::initialized(const Variant &p_params) {
|
|||
notify_client("gdscript/capabilities", capabilities.to_json());
|
||||
}
|
||||
|
||||
void GDScriptLanguageProtocol::poll() {
|
||||
void GDScriptLanguageProtocol::poll(int p_limit_usec) {
|
||||
uint64_t target_ticks = OS::get_singleton()->get_ticks_usec() + p_limit_usec;
|
||||
|
||||
if (server->is_connection_available()) {
|
||||
on_client_connected();
|
||||
}
|
||||
|
@ -244,16 +246,22 @@ void GDScriptLanguageProtocol::poll() {
|
|||
E = clients.begin();
|
||||
continue;
|
||||
} else {
|
||||
if (peer->connection->get_available_bytes() > 0) {
|
||||
Error err = OK;
|
||||
while (peer->connection->get_available_bytes() > 0) {
|
||||
latest_client_id = E->key;
|
||||
Error err = peer->handle_data();
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(E->key);
|
||||
E = clients.begin();
|
||||
continue;
|
||||
err = peer->handle_data();
|
||||
if (err != OK || OS::get_singleton()->get_ticks_usec() >= target_ticks) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Error err = peer->send_data();
|
||||
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(E->key);
|
||||
E = clients.begin();
|
||||
continue;
|
||||
}
|
||||
|
||||
err = peer->send_data();
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(E->key);
|
||||
E = clients.begin();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue