Skip to content

Commit

Permalink
Add support for connecting to files/unix sockets.
Browse files Browse the repository at this point in the history
Closes mqttjs#1040.
  • Loading branch information
ralight committed Feb 12, 2020
1 parent ea439b1 commit 6c78010
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Connects to the broker specified by the given url and options and
returns a [Client](#client).

The URL can be on the following protocols: 'mqtt', 'mqtts', 'tcp',
'tls', 'ws', 'wss'. The URL can also be an object as returned by
'tls', 'ws', 'wss', 'file' (e.g. unix socket). The URL can also be an object as returned by
[`URL.parse()`](http://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost),
in that case the two objects are merged, i.e. you can pass a single
object with both the URL and the connect options.
Expand Down
8 changes: 8 additions & 0 deletions lib/connect/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'
var net = require('net')

function buildBuilder (client, opts) {
return net.createConnection(opts.pathname)
}

module.exports = buildBuilder
1 change: 1 addition & 0 deletions lib/connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if (process.title !== 'browser') {
protocols.ssl = require('./tls')
protocols.tls = require('./tls')
protocols.mqtts = require('./tls')
protocols.file = require('./file')
} else {
protocols.wx = require('./wx')
protocols.wxs = require('./wx')
Expand Down

0 comments on commit 6c78010

Please sign in to comment.