-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
133 lines (121 loc) · 4.49 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const ClientMessageRelay = require('./lib/message_relay_client.js')
const ServerMessageRelay = require('./lib/message_relay.js')
const ServerMessageEndpoint = require('./lib/message_endpoint.js')
const MultiRelayClient = require('./lib/mutli_relay_client')
const MultiPathRelayClient = require('./lib/mutli_path_relay_client')
//
const {PathHandler,PeerPublishingHandler,classes} = require('./path-handler/path-handler')
const ServerWithIPC = require('./lib/message_endpoint_as_child_with_ipc')
const IPCClient = require('./lib/message_relay_ipc')
const IPCChildClient = require('./lib/message_relay_ipc_source')
const ParentIPCMessenger = require('./lib/parent_ipc_message_relay.js')
//
const JSONMessageQueue = require('./json-message-queue')
const ResponseVector = require('./response-vector')
//
const UDPClient = require('./lib/message_relay_udp')
const UDPEndpoint = require('./lib/message_endpoint_udp')
const MulticastClient = require('./lib/message_relay_multicast')
const MulticastEndpoint = require('./lib/message_endpoint_multicast')
//
const MessageRelayContainer = require('./client-producer/cprod')
const MessageRelayManager = require('./client-producer/cmanager')
//
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
//
module.exports.MessageRelayer = ClientMessageRelay
module.exports.ServeMessageRelay = ServerMessageRelay
module.exports.ServeMessageEndpoint = ServerMessageEndpoint
//
module.exports.PathHandler = PathHandler
module.exports.PeerPublishingHandler = PeerPublishingHandler
module.exports.path_hanlder_classes = classes
module.exports.MultiRelayClient = MultiRelayClient
module.exports.MultiPathRelayClient = MultiPathRelayClient
//
module.exports.RelayCommunicator = ServerMessageRelay.Communicator
module.exports.EndpointCommunicator = ServerMessageEndpoint.Communicator
module.exports.MessengerCommunicator = ClientMessageRelay.Communicator
module.exports.MessengerCommunicatorAPI = ClientMessageRelay.CommunicatorAPI
module.exports.JSONMessageQueue = JSONMessageQueue
//
module.exports.ResponseVector = ResponseVector
//
//
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
//
module.exports.ServerWithIPC = ServerWithIPC
module.exports.IPCClient = IPCClient
module.exports.IPCChildClient = IPCChildClient
module.exports.ParentIPCMessenger = ParentIPCMessenger
module.exports.ServerWithIPCommunicator = ServerWithIPC.Communicator
module.exports.IPCClientCommunicator = IPCClient.Communicator
module.exports.IPCChildClientCommunicator = IPCChildClient.Communicator
module.exports.JsonMessageHandlerRelay = ServerMessageRelay.JsonMessageHandlerRelay
module.exports.EndpointReplier = ServerMessageEndpoint.EndpointReplier
module.exports.UDPClient = UDPClient
module.exports.UDPEndpoint = UDPEndpoint
//
module.exports.MessageRelayContainer = MessageRelayContainer
module.exports.MessageRelayManager = MessageRelayManager
//
module.exports.MulticastClient = MulticastClient
module.exports.MulticastEndpoint = MulticastEndpoint
//
/**
*
* @param {object} conf
* @param {object} wrapper
* @param {Function} reporter
* @returns
*/
module.exports.new_client_relay = async (conf,wrapper,reporter) => {
let relayer = new ClientMessageRelay(conf,wrapper)
let p = new Promise((resolve,reject) => {
relayer.on('client-ready',(address,port) => {
if ( typeof reporter === 'function' ) {
reporter(address,port)
}
resolve(relayer)
})
})
return p
}
/**
*
* @param {object} conf
* @param {object} wrapper
* @param {Function} reporter
* @returns
*/
module.exports.new_multi_peer_relay = async (conf,wrapper,reporter) => {
let relayer = new MultiRelayClient(conf,wrapper)
let p = new Promise((resolve,reject) => {
relayer.on('peer-ready',(descr) => {
if ( typeof reporter === 'function' ) {
reporter(descr.address,descr.port,descrp['configured-address'])
}
resolve(relayer)
})
})
return p
}
/**
*
* @param {object} conf
* @param {object} wrapper
* @param {Function} reporter
* @returns
*/
module.exports.new_multi_path_relay = async (conf,wrapper,reporter) => {
let relayer = new MultiPathRelayClient(conf,wrapper)
let p = new Promise((resolve,reject) => {
relayer.on('peer-ready',(descr) => {
if ( typeof reporter === 'function' ) {
reporter(descr.path,descr.address,descr.port,descrp['configured-address'])
}
resolve(relayer)
})
})
return p
}