projects
/
KiwiIRC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Server: Force data to be sent ahead of a write queue
[KiwiIRC.git]
/
server
/
irc
/
connection.js
diff --git
a/server/irc/connection.js
b/server/irc/connection.js
index 00822f719eef5bec447bf667a13186b46584f2f9..d8bf8048f708464fb155b524ab8d41e1bfb9f84f 100644
(file)
--- a/
server/irc/connection.js
+++ b/
server/irc/connection.js
@@
-263,11
+263,18
@@
IrcConnection.prototype.clientEvent = function (event_name, data, callback) {
/**
* Write a line of data to the IRCd
/**
* Write a line of data to the IRCd
+ * @param data The line of data to be sent
+ * @param force Write the data now, ignoring any write queue
*/
*/
-IrcConnection.prototype.write = function (data,
callback
) {
+IrcConnection.prototype.write = function (data,
force
) {
//ENCODE string to encoding of the server
encoded_buffer = iconv.encode(data + '\r\n', this.encoding);
//ENCODE string to encoding of the server
encoded_buffer = iconv.encode(data + '\r\n', this.encoding);
+ if (force) {
+ this.socket.write(encoded_buffer);
+ return;
+ }
+
this.write_buffer.push(encoded_buffer);
// Only flush if we're not writing already
this.write_buffer.push(encoded_buffer);
// Only flush if we're not writing already
@@
-325,11
+332,14
@@
IrcConnection.prototype.flushWriteBuffer = function () {
/**
/**
- * Close the connection to the IRCd after
send
ing one last line
+ * Close the connection to the IRCd after
forc
ing one last line
*/
IrcConnection.prototype.end = function (data, callback) {
*/
IrcConnection.prototype.end = function (data, callback) {
+ if (!this.socket)
+ return;
+
if (data)
if (data)
- this.write(data);
+ this.write(data
, true
);
this.socket.end();
};
this.socket.end();
};