-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (57 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Module dependencies
*/
var type = require('./lib/message/type')
var Socket = require('./lib/socket/index')
var SocketChannel = require('./lib/socket/channel')
/**
* SocketMQ main module
*/
var socketmq = module.exports = function() {
return new Socket()
}
/**
* Expose types
* @type {Object}
*/
socketmq.type = type
/**
* Expose Socket constructor
* @type {Function}
*/
socketmq.Socket = Socket
/**
* Create a new SocketMQ instance and bind to endpoint.
* @type {Function}
*/
socketmq.bind = function(uri, options, callback) {
var smq = socketmq()
smq.bind(uri, options, callback)
return smq
}
/**
* Create a new SocketMQ instance and connect to endpoint.
* @type {Function}
*/
socketmq.connect = function(uri, options, callback) {
var smq = socketmq()
smq.connect(uri, options, callback)
return smq
}
/**
* Channel constructor
*/
socketmq.channel = function(ns, name) {
return new SocketChannel(null, ns, name)
}
/**
* Server constructors
*/
socketmq.hub = function() {
var SocketHub = require('./lib/socket' + '/hub')
return new SocketHub()
}
socketmq.gateway = function() {
var SocketGateway = require('./lib/socket' + '/gateway')
return new SocketGateway()
}