make the class instance the default context for packet commands

tls
David Kebler 2018-01-28 12:33:26 -08:00
parent 1b846c4753
commit bb0ca93e43
2 changed files with 4 additions and 5 deletions

View File

@ -10,7 +10,7 @@ export default class Consumer extends Socket {
// set or tcp socket
if (typeof(path)!=='string') {
opts = path
this.host = opts.host || '127.0.0.1'
this.host = opts.host || '127.0.0.1' // TODO log a warning about host on same machine
this.port = opts.port || 8080
} else this.path = path
this.packet = {
@ -46,9 +46,7 @@ export default class Consumer extends Socket {
async connect (context) {
if (context) this.packet.context = context
// console.log('consumer processing=>',app.pp,'=>', app[app.pp])
// console.log('========================')
else this.packet.context = this
this.listen()
this.log.info('listening')

View File

@ -12,7 +12,7 @@ export default class Socket extends Server {
// set or tcp socket
if (typeof(path)!=='string') {
opts = path
this.listen_opts = { host: opts.host || '127.0.0.1', port: opts.port || 8080}
this.listen_opts = { host: opts.host || '0.0.0.0', port: opts.port || 8080}
} else this.listen_opts = { path: path }
// default packet processing
this.packet = {
@ -36,6 +36,7 @@ export default class Socket extends Server {
async create (context) {
if (context) this.packet.context = context
else this.packet.context = this
return new Promise( async (resolve,reject) => {