Comparing version
@@ -121,3 +121,3 @@ /** | ||
} = options; | ||
if ( !host || !port || !channel_id ) { | ||
if (!channel_id) { | ||
throw new Error("Destination host, port and channel_id must be assigned!"); | ||
@@ -193,2 +193,20 @@ } | ||
Object.defineProperties(inst, { | ||
connect: { | ||
enumerable:true, | ||
value:function(port, host) { | ||
if ( client.state === 1 ) return this; | ||
client.remote_host = host; | ||
client.remote_port = port; | ||
return BuildConnection(client); | ||
} | ||
}, | ||
close: { | ||
enumerable:true, | ||
value:function() { | ||
return new Promise((resolve, reject)=>{ | ||
client.socket.end((err)=>err?reject(err):resolve()); | ||
}); | ||
} | ||
}, | ||
invoke: { | ||
@@ -285,3 +303,8 @@ enumerable:true, | ||
}); | ||
return BuildConnection(client); | ||
if ( host !== undefined || port !== undefined ) { | ||
return BuildConnection(client); | ||
} | ||
return inst; | ||
}; | ||
@@ -288,0 +311,0 @@ function BuildConnection(client) { |
@@ -249,2 +249,4 @@ #!/usr/bin/env node | ||
const {room} = client; | ||
@@ -257,2 +259,3 @@ const paired_client = (room.A===client)?room.B:room.A; | ||
} | ||
console.log(`[${GetLocalISOString()}] MCHE, ${client.id}, len:${client.chunk.length}`); | ||
continue; | ||
@@ -262,2 +265,3 @@ } | ||
console.log(`[${GetLocalISOString()}] MESG, ${client.id}, len:${client.chunk.length}`); | ||
if ( debug ) { | ||
@@ -264,0 +268,0 @@ console.log(`[${GetLocalISOString()}] DATA, ${client.id}, data:${client.chunk.toString('hex')}`); |
{ | ||
"name": "ipevt", | ||
"version": "0.9.10", | ||
"version": "0.9.11", | ||
"description": "A small library that allows peers to communicate via a central server", | ||
@@ -5,0 +5,0 @@ "main": "ipevt-client.js", |
@@ -19,3 +19,8 @@ /** | ||
client.on('disconnected', ()=>{ | ||
client | ||
.on('connected', ()=>{ | ||
console.log("connected 2"); | ||
}) | ||
.on('disconnected', ()=>{ | ||
console.log("disconnected"); | ||
@@ -22,0 +27,0 @@ process.exit(0); |
49794
1.47%1542
1.72%