projects
/
KiwiIRC.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2b99269
)
Wait until all QUIT command is sent to server before closing the socket
author
Darren
<darren@darrenwhitlen.com>
Wed, 16 Jul 2014 16:26:18 +0000
(17:26 +0100)
committer
Darren
<darren@darrenwhitlen.com>
Wed, 16 Jul 2014 16:26:18 +0000
(17:26 +0100)
server/irc/connection.js
patch
|
blob
|
blame
|
history
diff --git
a/server/irc/connection.js
b/server/irc/connection.js
index 6822a5a55b9ed01df79e9db86f763bd5109ffa1e..e19ef59fdbd6d72d17a4fea7de0e7a66b730fac3 100644
(file)
--- a/
server/irc/connection.js
+++ b/
server/irc/connection.js
@@
-343,12
+343,12
@@
IrcConnection.prototype.clientEvent = function (event_name, data, callback) {
* @param data The line of data to be sent
* @param force Write the data now, ignoring any write queue
*/
* @param data The line of data to be sent
* @param force Write the data now, ignoring any write queue
*/
-IrcConnection.prototype.write = function (data, force) {
+IrcConnection.prototype.write = function (data, force
, force_complete_fn
) {
//ENCODE string to encoding of the server
var encoded_buffer = iconv.encode(data + '\r\n', this.encoding);
if (force) {
//ENCODE string to encoding of the server
var encoded_buffer = iconv.encode(data + '\r\n', this.encoding);
if (force) {
- this.socket.write(encoded_buffer);
+ this.socket.write(encoded_buffer
, force_complete_fn
);
return;
}
return;
}
@@
-413,6
+413,8
@@
IrcConnection.prototype.flushWriteBuffer = function () {
* Close the connection to the IRCd after forcing one last line
*/
IrcConnection.prototype.end = function (data) {
* Close the connection to the IRCd after forcing one last line
*/
IrcConnection.prototype.end = function (data) {
+ var that = this;
+
if (!this.socket) {
return;
}
if (!this.socket) {
return;
}
@@
-420,7
+422,12
@@
IrcConnection.prototype.end = function (data) {
this.requested_disconnect = true;
if (data) {
this.requested_disconnect = true;
if (data) {
- this.write(data, true);
+ // Once the last bit of data has been sent, then re-run this function to close the socket
+ this.write(data, true, function() {
+ that.end();
+ });
+
+ return;
}
this.socket.end();
}
this.socket.end();