Skip to content
Snippets Groups Projects
Commit ad538657 authored by deuce's avatar deuce
Browse files

Use socket_select() to allow waiting on bith the IRC socket and the client

socket instead of the broken sleep(1) on input previously used.

This allows irc.js to run with MUCH lower CPU utilization.
parent 1b6ed913
No related branches found
No related tags found
No related merge requests found
......@@ -111,6 +111,9 @@ while(!connected) {
}
// Main loop
socks = new Array;
socks.push(sock);
socks.push(client.socket);
while(!quit) {
if(!sock.is_connected || !connected) {
alert("Lost connection");
......@@ -126,9 +129,16 @@ while(!quit) {
clean_exit();
}
screen.update();
ready=socket_select(socks, 1);
for(thissock in ready) {
if(ready[thissock]==0) { // IRC server
recieve_command();
}
if(ready[thissock]==1) { // Client
screen.update();
}
}
}
sock.close();
clean_exit();
......@@ -1242,12 +1252,12 @@ function Screen_update_input_line() {
}
function Screen_update() {
while(1) {
var key=console.inkey();
if(key!="") {
if(key!="")
this.handle_key(key);
}
else {
sleep(1);
else
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment