-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
98 lines (95 loc) · 2.28 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
var BrowserConnection = require('./browser-connection')
var ServerConnection = require('./server-connection')
var ClientSync = require('./client-sync')
var ServerSync = require('./server-sync')
var LocalPair = require('./local-pair')
var SyncError = require('./sync-error')
var Reconnect = require('./reconnect')
var BaseSync = require('./base-sync')
module.exports = {
BrowserConnection: BrowserConnection,
ServerConnection: ServerConnection,
ClientSync: ClientSync,
ServerSync: ServerSync,
LocalPair: LocalPair,
SyncError: SyncError,
Reconnect: Reconnect,
BaseSync: BaseSync
}
/**
* Logux protocol message. It is a array with message type string in first
* position and JS simple types in next.
*
* @typedef {Array} Message
* @property {string} 0 Message type
*/
/**
*
* Abstract interface for connection to sync over it.
* For example, WebSocket or Loopback.
*
* @name Connection
* @class
* @abstract
*/
/**
* Send message to connection.
*
* @param {Message} message Message to be sent
*
* @return {undefined}
*
* @name send
* @function
* @memberof Connection#
*/
/**
* Subscribe for connection events. It should implement nanoevents API.
* Supported events:
*
* * `connecting`: connection establishing was started.
* * `connect`: connection was established by any side.
* * `disconnect`: connection was closed by any side.
* * `message`: message was receive from other node.
* * `error`: message was wrong.
*
* @param {"connecting"|"connect"|"disconnect"|"message"|"error"} event Event.
* @param {function} listener The listener function.
*
* @return {function} Unbind listener from event.
*
* @name on
* @function
* @memberof Connection#
*/
/**
* Start connection. Connection should be in disconnected state
* from the beginning and start connection only on this method call.
*
* This method could be called again if connection moved to disconnected state.
*
* @return {undefined}
*
* @name connect
* @function
* @memberof Connection#
*/
/**
* Finish current connection.
*
* After disconnection, connection could be started again
* by {@link Connection#connect}.
*
* @return {undefined}
*
* @name disconnect
* @function
* @memberof Connection#
*/
/**
* Is connection is enabled.
*
* @name connected
* @type {boolean}
* @memberof Connection#
*/