Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
options.autoConnect == "undefined" ? true : options.autoConnect;
options.preventAutoReconnect = false;
options.logLevel = options.logLevel || "WARN";
util.log(`[mcprotocol] adding new connection to pool ~ ${id}`);
console.log(`[mcprotocol] adding new connection to pool ~ ${id}`);

var mcp = new mcprotocol();

Expand Down Expand Up @@ -97,10 +97,10 @@ module.exports = {
disconnect: function() {
this._instances -= 1;
if (this._instances <= 0) {
util.log(`[mcprotocol] closing connection ~ ${id}`);
console.log(`[mcprotocol] closing connection ~ ${id}`);
mcp.dropConnection();
mcp = null;
util.log(`[mcprotocol] deleting connection from pool ~ ${id}`);
console.log(`[mcprotocol] deleting connection from pool ~ ${id}`);
delete pool[id];
}
},
Expand All @@ -119,12 +119,12 @@ module.exports = {

mcp.on("error", function(e) {
if (mcp) {
util.log(`[mcprotocol] error ~ ${id}: ${e}`);
console.log(`[mcprotocol] error ~ ${id}: ${e}`);
connecting = false;
if (options.autoConnect) {
setTimeout(function() {
if (options.autoConnect && !options.preventAutoReconnect) {
util.log(
console.log(
`[mcprotocol] autoConnect call from error handler ~ ${id}`
);
obj.connect();
Expand All @@ -135,17 +135,17 @@ module.exports = {
});
mcp.on("open", function() {
if (mcp) {
util.log(`[mcprotocol] connected ~ ${id}`);
console.log(`[mcprotocol] connected ~ ${id}`);
connecting = false;
}
});
mcp.on("close", function(err) {
util.log(`[mcprotocol] connection closed ~ ${id}`);
console.log(`[mcprotocol] connection closed ~ ${id}`);
connecting = false;
if (options.autoConnect) {
setTimeout(function() {
if (options.autoConnect && !options.preventAutoReconnect) {
util.log(
console.log(
`[mcprotocol] autoConnect call from close handler ~ ${id}`
);
obj.connect();
Expand Down