@bigtyphoon/melo 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +55 -0
  3. package/bin/commadtest.ts +10 -0
  4. package/bin/commands/add.ts +43 -0
  5. package/bin/commands/init.ts +292 -0
  6. package/bin/commands/kill.ts +21 -0
  7. package/bin/commands/list.ts +60 -0
  8. package/bin/commands/masterha.ts +40 -0
  9. package/bin/commands/restart.ts +48 -0
  10. package/bin/commands/start.ts +65 -0
  11. package/bin/commands/stop.ts +26 -0
  12. package/bin/melo.ts +30 -0
  13. package/bin/utils/constants.ts +27 -0
  14. package/bin/utils/utils.ts +130 -0
  15. package/dist/bin/commadtest.js +9 -0
  16. package/dist/bin/commands/add.js +40 -0
  17. package/dist/bin/commands/init.js +279 -0
  18. package/dist/bin/commands/kill.js +21 -0
  19. package/dist/bin/commands/list.js +65 -0
  20. package/dist/bin/commands/masterha.js +36 -0
  21. package/dist/bin/commands/restart.js +45 -0
  22. package/dist/bin/commands/start.js +58 -0
  23. package/dist/bin/commands/stop.js +20 -0
  24. package/dist/bin/melo.js +26 -0
  25. package/dist/bin/utils/constants.js +28 -0
  26. package/dist/bin/utils/utils.js +134 -0
  27. package/dist/lib/application.js +888 -0
  28. package/dist/lib/common/manager/appManager.js +112 -0
  29. package/dist/lib/common/manager/taskManager.js +39 -0
  30. package/dist/lib/common/remote/backend/msgRemote.js +63 -0
  31. package/dist/lib/common/remote/frontend/channelRemote.js +78 -0
  32. package/dist/lib/common/remote/frontend/sessionRemote.js +76 -0
  33. package/dist/lib/common/service/backendSessionService.js +337 -0
  34. package/dist/lib/common/service/channelService.js +514 -0
  35. package/dist/lib/common/service/connectionService.js +95 -0
  36. package/dist/lib/common/service/filterService.js +112 -0
  37. package/dist/lib/common/service/handlerService.js +187 -0
  38. package/dist/lib/common/service/sessionService.js +610 -0
  39. package/dist/lib/components/backendSession.js +14 -0
  40. package/dist/lib/components/channel.js +13 -0
  41. package/dist/lib/components/connection.js +12 -0
  42. package/dist/lib/components/connector.js +437 -0
  43. package/dist/lib/components/dictionary.js +93 -0
  44. package/dist/lib/components/master.js +39 -0
  45. package/dist/lib/components/monitor.js +25 -0
  46. package/dist/lib/components/protobuf.js +156 -0
  47. package/dist/lib/components/proxy.js +236 -0
  48. package/dist/lib/components/pushScheduler.js +62 -0
  49. package/dist/lib/components/remote.js +127 -0
  50. package/dist/lib/components/server.js +63 -0
  51. package/dist/lib/components/session.js +20 -0
  52. package/dist/lib/connectors/commands/handshake.js +119 -0
  53. package/dist/lib/connectors/commands/heartbeat.js +67 -0
  54. package/dist/lib/connectors/commands/kick.js +15 -0
  55. package/dist/lib/connectors/common/coder.js +90 -0
  56. package/dist/lib/connectors/common/handler.js +57 -0
  57. package/dist/lib/connectors/hybrid/IHybridSocket.js +3 -0
  58. package/dist/lib/connectors/hybrid/switcher.js +100 -0
  59. package/dist/lib/connectors/hybrid/tcpprocessor.js +40 -0
  60. package/dist/lib/connectors/hybrid/tcpsocket.js +171 -0
  61. package/dist/lib/connectors/hybrid/wsprocessor.js +49 -0
  62. package/dist/lib/connectors/hybridconnector.js +89 -0
  63. package/dist/lib/connectors/hybridsocket.js +139 -0
  64. package/dist/lib/connectors/mqtt/generate.js +113 -0
  65. package/dist/lib/connectors/mqtt/mqttadaptor.js +81 -0
  66. package/dist/lib/connectors/mqtt/protocol.js +48 -0
  67. package/dist/lib/connectors/mqttconnector.js +107 -0
  68. package/dist/lib/connectors/mqttsocket.js +59 -0
  69. package/dist/lib/connectors/sioconnector.js +135 -0
  70. package/dist/lib/connectors/siosocket.js +69 -0
  71. package/dist/lib/connectors/udpconnector.js +76 -0
  72. package/dist/lib/connectors/udpsocket.js +93 -0
  73. package/dist/lib/filters/handler/serial.js +44 -0
  74. package/dist/lib/filters/handler/time.js +32 -0
  75. package/dist/lib/filters/handler/timeout.js +45 -0
  76. package/dist/lib/filters/handler/toobusy.js +36 -0
  77. package/dist/lib/filters/rpc/rpcLog.js +43 -0
  78. package/dist/lib/filters/rpc/toobusy.js +41 -0
  79. package/dist/lib/index.js +81 -0
  80. package/dist/lib/interfaces/IComponent.js +3 -0
  81. package/dist/lib/interfaces/IConnector.js +3 -0
  82. package/dist/lib/interfaces/IHandlerFilter.js +3 -0
  83. package/dist/lib/interfaces/ILifeCycle.js +3 -0
  84. package/dist/lib/interfaces/IPlugin.js +3 -0
  85. package/dist/lib/interfaces/IPushScheduler.js +3 -0
  86. package/dist/lib/interfaces/ISocket.js +3 -0
  87. package/dist/lib/interfaces/IStore.js +3 -0
  88. package/dist/lib/interfaces/define.js +3 -0
  89. package/dist/lib/master/master.js +129 -0
  90. package/dist/lib/master/starter.js +236 -0
  91. package/dist/lib/master/watchdog.js +120 -0
  92. package/dist/lib/melo.js +125 -0
  93. package/dist/lib/modules/console.js +436 -0
  94. package/dist/lib/modules/masterwatcher.js +98 -0
  95. package/dist/lib/modules/monitorwatcher.js +124 -0
  96. package/dist/lib/modules/onlineUser.js +69 -0
  97. package/dist/lib/modules/restartNotifyModule.js +107 -0
  98. package/dist/lib/modules/watchServer.js +737 -0
  99. package/dist/lib/monitor/monitor.js +80 -0
  100. package/dist/lib/pushSchedulers/buffer.js +96 -0
  101. package/dist/lib/pushSchedulers/direct.js +58 -0
  102. package/dist/lib/pushSchedulers/multi.js +80 -0
  103. package/dist/lib/server/server.js +500 -0
  104. package/dist/lib/util/appUtil.js +306 -0
  105. package/dist/lib/util/constants.js +117 -0
  106. package/dist/lib/util/countDownLatch.js +51 -0
  107. package/dist/lib/util/events.js +20 -0
  108. package/dist/lib/util/handlerHelper.js +8 -0
  109. package/dist/lib/util/log.js +14 -0
  110. package/dist/lib/util/moduleUtil.js +101 -0
  111. package/dist/lib/util/pathUtil.js +134 -0
  112. package/dist/lib/util/remoterHelper.js +8 -0
  113. package/dist/lib/util/utils.js +358 -0
  114. package/dist/test/application.js +522 -0
  115. package/dist/test/config/log4js.json +28 -0
  116. package/dist/test/config/master.json +9 -0
  117. package/dist/test/config/servers.json +6 -0
  118. package/dist/test/filters/handler/serial.js +41 -0
  119. package/dist/test/filters/handler/time.js +41 -0
  120. package/dist/test/filters/handler/timeout.js +41 -0
  121. package/dist/test/filters/handler/toobusy.js +57 -0
  122. package/dist/test/filters/rpc/rpcLog.js +22 -0
  123. package/dist/test/filters/rpc/toobusy.js +39 -0
  124. package/dist/test/manager/mockChannelManager.js +77 -0
  125. package/dist/test/manager/taskManager.js +68 -0
  126. package/dist/test/mock-base/app/servers/other-file +0 -0
  127. package/dist/test/mock-plugin/components/mockPlugin.js +10 -0
  128. package/dist/test/mock-plugin/events/mockEvent.js +12 -0
  129. package/dist/test/modules/console.js +242 -0
  130. package/dist/test/pomelo.js +19 -0
  131. package/dist/test/remote/channelRemote.js +159 -0
  132. package/dist/test/service/channel.js +134 -0
  133. package/dist/test/service/channelService.js +216 -0
  134. package/dist/test/service/connectionService.js +114 -0
  135. package/dist/test/service/filterService.js +144 -0
  136. package/dist/test/service/handlerService.js +65 -0
  137. package/dist/test/service/sessionService.js +387 -0
  138. package/dist/test/util/countDownLatch.js +70 -0
  139. package/dist/test/util/pathUtil.js +108 -0
  140. package/dist/test/util/utils.js +140 -0
  141. package/lib/application.ts +1240 -0
  142. package/lib/common/manager/appManager.ts +118 -0
  143. package/lib/common/manager/taskManager.ts +50 -0
  144. package/lib/common/remote/backend/msgRemote.ts +134 -0
  145. package/lib/common/remote/frontend/channelRemote.ts +91 -0
  146. package/lib/common/remote/frontend/sessionRemote.ts +91 -0
  147. package/lib/common/service/backendSessionService.ts +388 -0
  148. package/lib/common/service/channelService.ts +609 -0
  149. package/lib/common/service/connectionService.ts +112 -0
  150. package/lib/common/service/filterService.ts +118 -0
  151. package/lib/common/service/handlerService.ts +224 -0
  152. package/lib/common/service/sessionService.ts +731 -0
  153. package/lib/components/backendSession.ts +14 -0
  154. package/lib/components/channel.ts +11 -0
  155. package/lib/components/connection.ts +13 -0
  156. package/lib/components/connector.ts +533 -0
  157. package/lib/components/dictionary.ts +121 -0
  158. package/lib/components/master.ts +41 -0
  159. package/lib/components/monitor.ts +30 -0
  160. package/lib/components/protobuf.ts +208 -0
  161. package/lib/components/proxy.ts +282 -0
  162. package/lib/components/pushScheduler.ts +70 -0
  163. package/lib/components/remote.ts +166 -0
  164. package/lib/components/server.ts +71 -0
  165. package/lib/components/session.ts +22 -0
  166. package/lib/connectors/commands/handshake.ts +155 -0
  167. package/lib/connectors/commands/heartbeat.ts +83 -0
  168. package/lib/connectors/commands/kick.ts +11 -0
  169. package/lib/connectors/common/coder.ts +93 -0
  170. package/lib/connectors/common/handler.ts +62 -0
  171. package/lib/connectors/hybrid/IHybridSocket.ts +9 -0
  172. package/lib/connectors/hybrid/switcher.ts +142 -0
  173. package/lib/connectors/hybrid/tcpprocessor.ts +43 -0
  174. package/lib/connectors/hybrid/tcpsocket.ts +223 -0
  175. package/lib/connectors/hybrid/wsprocessor.ts +57 -0
  176. package/lib/connectors/hybridconnector.ts +134 -0
  177. package/lib/connectors/hybridsocket.ts +168 -0
  178. package/lib/connectors/mqtt/generate.ts +103 -0
  179. package/lib/connectors/mqtt/mqttadaptor.ts +114 -0
  180. package/lib/connectors/mqtt/protocol.ts +49 -0
  181. package/lib/connectors/mqttconnector.ts +134 -0
  182. package/lib/connectors/mqttsocket.ts +79 -0
  183. package/lib/connectors/sioconnector.ts +161 -0
  184. package/lib/connectors/siosocket.ts +85 -0
  185. package/lib/connectors/udpconnector.ts +113 -0
  186. package/lib/connectors/udpsocket.ts +110 -0
  187. package/lib/filters/handler/serial.ts +46 -0
  188. package/lib/filters/handler/time.ts +35 -0
  189. package/lib/filters/handler/timeout.ts +50 -0
  190. package/lib/filters/handler/toobusy.ts +37 -0
  191. package/lib/filters/rpc/rpcLog.ts +42 -0
  192. package/lib/filters/rpc/toobusy.ts +41 -0
  193. package/lib/index.ts +74 -0
  194. package/lib/interfaces/IComponent.ts +47 -0
  195. package/lib/interfaces/IConnector.ts +20 -0
  196. package/lib/interfaces/IHandlerFilter.ts +15 -0
  197. package/lib/interfaces/ILifeCycle.ts +16 -0
  198. package/lib/interfaces/IPlugin.ts +65 -0
  199. package/lib/interfaces/IPushScheduler.ts +52 -0
  200. package/lib/interfaces/ISocket.ts +26 -0
  201. package/lib/interfaces/IStore.ts +10 -0
  202. package/lib/interfaces/define.ts +15 -0
  203. package/lib/master/master.ts +148 -0
  204. package/lib/master/starter.ts +234 -0
  205. package/lib/master/watchdog.ts +135 -0
  206. package/lib/melo.ts +152 -0
  207. package/lib/modules/console.ts +465 -0
  208. package/lib/modules/masterwatcher.ts +120 -0
  209. package/lib/modules/monitorwatcher.ts +151 -0
  210. package/lib/modules/onlineUser.ts +78 -0
  211. package/lib/modules/restartNotifyModule.ts +128 -0
  212. package/lib/modules/watchServer.ts +766 -0
  213. package/lib/monitor/monitor.ts +99 -0
  214. package/lib/pushSchedulers/buffer.ts +117 -0
  215. package/lib/pushSchedulers/direct.ts +65 -0
  216. package/lib/pushSchedulers/multi.ts +94 -0
  217. package/lib/server/server.ts +554 -0
  218. package/lib/util/appUtil.ts +313 -0
  219. package/lib/util/constants.ts +154 -0
  220. package/lib/util/countDownLatch.ts +72 -0
  221. package/lib/util/events.ts +15 -0
  222. package/lib/util/handlerHelper.ts +5 -0
  223. package/lib/util/log.ts +11 -0
  224. package/lib/util/moduleUtil.ts +110 -0
  225. package/lib/util/pathUtil.ts +132 -0
  226. package/lib/util/remoterHelper.ts +68 -0
  227. package/lib/util/utils.ts +365 -0
  228. package/package.json +93 -0
  229. package/template/game-server/.vscode/launch.json +27 -0
  230. package/template/game-server/app/servers/connector/handler/entryHandler.ts +50 -0
  231. package/template/game-server/app/servers/connector/remote/authRemoter.ts +36 -0
  232. package/template/game-server/app.ts +30 -0
  233. package/template/game-server/app.ts.mqtt +32 -0
  234. package/template/game-server/app.ts.sio +36 -0
  235. package/template/game-server/app.ts.sio.wss +34 -0
  236. package/template/game-server/app.ts.udp +31 -0
  237. package/template/game-server/app.ts.wss +40 -0
  238. package/template/game-server/config/adminServer.json +5 -0
  239. package/template/game-server/config/adminUser.json +22 -0
  240. package/template/game-server/config/clientProtos.json +1 -0
  241. package/template/game-server/config/dictionary.json +1 -0
  242. package/template/game-server/config/log4js.json +150 -0
  243. package/template/game-server/config/master.json +8 -0
  244. package/template/game-server/config/serverProtos.json +1 -0
  245. package/template/game-server/config/servers.json +12 -0
  246. package/template/game-server/copy.js +5 -0
  247. package/template/game-server/package.json +28 -0
  248. package/template/game-server/preload.ts +40 -0
  249. package/template/game-server/tsconfig.json +36 -0
  250. package/template/npm-install.bat +4 -0
  251. package/template/npm-install.sh +5 -0
  252. package/template/readme.md +31 -0
  253. package/template/shared/server.crt +15 -0
  254. package/template/shared/server.key +15 -0
  255. package/template/web-server/app.js +25 -0
  256. package/template/web-server/app.js.https +36 -0
  257. package/template/web-server/bin/component.bat +1 -0
  258. package/template/web-server/bin/component.sh +1 -0
  259. package/template/web-server/package.json +10 -0
  260. package/template/web-server/public/css/base.css +76 -0
  261. package/template/web-server/public/image/logo.png +0 -0
  262. package/template/web-server/public/image/sp.png +0 -0
  263. package/template/web-server/public/index.html +57 -0
  264. package/template/web-server/public/index.html.sio +58 -0
  265. package/template/web-server/public/js/lib/build/build.js +1730 -0
  266. package/template/web-server/public/js/lib/build/build.js.wss +1721 -0
  267. package/template/web-server/public/js/lib/component.json +6 -0
  268. package/template/web-server/public/js/lib/local/boot/component.json +11 -0
  269. package/template/web-server/public/js/lib/local/boot/index.js +11 -0
  270. package/template/web-server/public/js/lib/meloclient.js +456 -0
  271. package/template/web-server/public/js/lib/meloclient.js.wss +456 -0
  272. package/template/web-server/public/js/lib/socket.io.js +3 -0
  273. package/test/application.ts +607 -0
  274. package/test/filters/handler/serial.ts +47 -0
  275. package/test/filters/handler/time.ts +47 -0
  276. package/test/filters/handler/timeout.ts +46 -0
  277. package/test/filters/handler/toobusy.ts +59 -0
  278. package/test/filters/rpc/rpcLog.ts +20 -0
  279. package/test/filters/rpc/toobusy.ts +40 -0
  280. package/test/manager/mockChannelManager.ts +92 -0
  281. package/test/manager/taskManager.ts +78 -0
  282. package/test/mock-base/app/servers/other-file +0 -0
  283. package/test/mock-plugin/components/mockPlugin.ts +8 -0
  284. package/test/mock-plugin/events/mockEvent.ts +12 -0
  285. package/test/modules/console.ts +264 -0
  286. package/test/pomelo.ts +18 -0
  287. package/test/remote/channelRemote.ts +176 -0
  288. package/test/service/channel.ts +161 -0
  289. package/test/service/channelService.ts +243 -0
  290. package/test/service/connectionService.ts +142 -0
  291. package/test/service/filterService.ts +165 -0
  292. package/test/service/handlerService.ts +77 -0
  293. package/test/service/sessionService.ts +464 -0
  294. package/test/util/countDownLatch.ts +81 -0
  295. package/test/util/pathUtil.ts +122 -0
  296. package/test/util/utils.ts +165 -0
@@ -0,0 +1,1730 @@
1
+
2
+
3
+ /**
4
+ * hasOwnProperty.
5
+ */
6
+
7
+ var has = Object.prototype.hasOwnProperty;
8
+
9
+ /* Refer to https://github.com/componentjs/require/blob/master/lib/require.js */
10
+ /**
11
+ * Require the given path.
12
+ *
13
+ * @param {String} path
14
+ * @return {Object} exports
15
+ * @api public
16
+ */
17
+
18
+ function require(path, parent, orig) {
19
+ var resolved = require.resolve(path);
20
+
21
+ // lookup failed
22
+ if (null == resolved) {
23
+ orig = orig || path;
24
+ parent = parent || 'root';
25
+ var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
26
+ err.path = orig;
27
+ err.parent = parent;
28
+ err.require = true;
29
+ throw err;
30
+ }
31
+
32
+ var module = require.modules[resolved];
33
+
34
+ // perform real require()
35
+ // by invoking the module's
36
+ // registered function
37
+ if (!module.exports) {
38
+ module.exports = {};
39
+ module.client = module.component = true;
40
+ module.call(this, module.exports, require.relative(resolved), module);
41
+ }
42
+
43
+ return module.exports;
44
+ }
45
+
46
+ /**
47
+ * Registered modules.
48
+ */
49
+
50
+ require.modules = {};
51
+
52
+ /**
53
+ * Registered aliases.
54
+ */
55
+
56
+ require.aliases = {};
57
+
58
+ /**
59
+ * Resolve `path`.
60
+ *
61
+ * Lookup:
62
+ *
63
+ * - PATH/index.js
64
+ * - PATH.js
65
+ * - PATH
66
+ *
67
+ * @param {String} path
68
+ * @return {String} path or null
69
+ * @api private
70
+ */
71
+
72
+ require.resolve = function(path) {
73
+ if (path.charAt(0) === '/') path = path.slice(1);
74
+ var index = path + '/index.js';
75
+
76
+ var paths = [
77
+ path,
78
+ path + '.js',
79
+ path + '.json',
80
+ path + '/index.js',
81
+ path + '/index.json'
82
+ ];
83
+
84
+ for (var i = 0; i < paths.length; i++) {
85
+ var path = paths[i];
86
+ if (has.call(require.modules, path)) return path;
87
+ }
88
+
89
+ if (has.call(require.aliases, index)) {
90
+ return require.aliases[index];
91
+ }
92
+ };
93
+
94
+ /**
95
+ * Normalize `path` relative to the current path.
96
+ *
97
+ * @param {String} curr
98
+ * @param {String} path
99
+ * @return {String}
100
+ * @api private
101
+ */
102
+
103
+ require.normalize = function(curr, path) {
104
+ var segs = [];
105
+
106
+ if ('.' != path.charAt(0)) return path;
107
+
108
+ curr = curr.split('/');
109
+ path = path.split('/');
110
+
111
+ for (var i = 0; i < path.length; ++i) {
112
+ if ('..' == path[i]) {
113
+ curr.pop();
114
+ } else if ('.' != path[i] && '' != path[i]) {
115
+ segs.push(path[i]);
116
+ }
117
+ }
118
+
119
+ return curr.concat(segs).join('/');
120
+ };
121
+
122
+ /**
123
+ * Register module at `path` with callback `definition`.
124
+ *
125
+ * @param {String} path
126
+ * @param {Function} definition
127
+ * @api private
128
+ */
129
+
130
+ require.register = function(path, definition) {
131
+ require.modules[path] = definition;
132
+ };
133
+
134
+ /**
135
+ * Alias a module definition.
136
+ *
137
+ * @param {String} from
138
+ * @param {String} to
139
+ * @api private
140
+ */
141
+
142
+ require.alias = function(from, to) {
143
+ if (!has.call(require.modules, from)) {
144
+ throw new Error('Failed to alias "' + from + '", it does not exist');
145
+ }
146
+ require.aliases[to] = from;
147
+ };
148
+
149
+ /**
150
+ * Return a require function relative to the `parent` path.
151
+ *
152
+ * @param {String} parent
153
+ * @return {Function}
154
+ * @api private
155
+ */
156
+
157
+ require.relative = function(parent) {
158
+ var p = require.normalize(parent, '..');
159
+
160
+ /**
161
+ * lastIndexOf helper.
162
+ */
163
+
164
+ function lastIndexOf(arr, obj) {
165
+ var i = arr.length;
166
+ while (i--) {
167
+ if (arr[i] === obj) return i;
168
+ }
169
+ return -1;
170
+ }
171
+
172
+ /**
173
+ * The relative require() itself.
174
+ */
175
+
176
+ function localRequire(path) {
177
+ var resolved = localRequire.resolve(path);
178
+ return require(resolved, parent, path);
179
+ }
180
+
181
+ /**
182
+ * Resolve relative to the parent.
183
+ */
184
+
185
+ localRequire.resolve = function(path) {
186
+ var c = path.charAt(0);
187
+ if ('/' == c) return path.slice(1);
188
+ if ('.' == c) return require.normalize(p, path);
189
+
190
+ // resolve deps by returning
191
+ // the dep in the nearest "deps"
192
+ // directory
193
+ var segs = parent.split('/');
194
+ var i = lastIndexOf(segs, 'deps') + 1;
195
+ if (!i) i = 0;
196
+ path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
197
+ return path;
198
+ };
199
+
200
+ /**
201
+ * Check if module is defined at `path`.
202
+ */
203
+
204
+ localRequire.exists = function(path) {
205
+ return has.call(require.modules, localRequire.resolve(path));
206
+ };
207
+
208
+ return localRequire;
209
+ };
210
+ require.register("component-indexof/index.js", function(exports, require, module){
211
+
212
+ var indexOf = [].indexOf;
213
+
214
+ module.exports = function(arr, obj){
215
+ if (indexOf) return arr.indexOf(obj);
216
+ for (var i = 0; i < arr.length; ++i) {
217
+ if (arr[i] === obj) return i;
218
+ }
219
+ return -1;
220
+ };
221
+ });
222
+ require.register("component-emitter/index.js", function(exports, require, module){
223
+
224
+ /**
225
+ * Module dependencies.
226
+ */
227
+
228
+ var index = require('indexof');
229
+
230
+ /**
231
+ * Expose `Emitter`.
232
+ */
233
+
234
+ module.exports = Emitter;
235
+
236
+ /**
237
+ * Initialize a new `Emitter`.
238
+ *
239
+ * @api public
240
+ */
241
+
242
+ function Emitter(obj) {
243
+ if (obj) return mixin(obj);
244
+ };
245
+
246
+ /**
247
+ * Mixin the emitter properties.
248
+ *
249
+ * @param {Object} obj
250
+ * @return {Object}
251
+ * @api private
252
+ */
253
+
254
+ function mixin(obj) {
255
+ for (var key in Emitter.prototype) {
256
+ obj[key] = Emitter.prototype[key];
257
+ }
258
+ return obj;
259
+ }
260
+
261
+ /**
262
+ * Listen on the given `event` with `fn`.
263
+ *
264
+ * @param {String} event
265
+ * @param {Function} fn
266
+ * @return {Emitter}
267
+ * @api public
268
+ */
269
+
270
+ Emitter.prototype.on = function(event, fn){
271
+ this._callbacks = this._callbacks || {};
272
+ (this._callbacks[event] = this._callbacks[event] || [])
273
+ .push(fn);
274
+ return this;
275
+ };
276
+
277
+ /**
278
+ * Adds an `event` listener that will be invoked a single
279
+ * time then automatically removed.
280
+ *
281
+ * @param {String} event
282
+ * @param {Function} fn
283
+ * @return {Emitter}
284
+ * @api public
285
+ */
286
+
287
+ Emitter.prototype.once = function(event, fn){
288
+ var self = this;
289
+ this._callbacks = this._callbacks || {};
290
+
291
+ function on() {
292
+ self.off(event, on);
293
+ fn.apply(this, arguments);
294
+ }
295
+
296
+ fn._off = on;
297
+ this.on(event, on);
298
+ return this;
299
+ };
300
+
301
+ /**
302
+ * Remove the given callback for `event` or all
303
+ * registered callbacks.
304
+ *
305
+ * @param {String} event
306
+ * @param {Function} fn
307
+ * @return {Emitter}
308
+ * @api public
309
+ */
310
+
311
+ Emitter.prototype.off =
312
+ Emitter.prototype.removeListener =
313
+ Emitter.prototype.removeAllListeners = function(event, fn){
314
+ this._callbacks = this._callbacks || {};
315
+
316
+ // all
317
+ if (0 == arguments.length) {
318
+ this._callbacks = {};
319
+ return this;
320
+ }
321
+
322
+ // specific event
323
+ var callbacks = this._callbacks[event];
324
+ if (!callbacks) return this;
325
+
326
+ // remove all handlers
327
+ if (1 == arguments.length) {
328
+ delete this._callbacks[event];
329
+ return this;
330
+ }
331
+
332
+ // remove specific handler
333
+ var i = index(callbacks, fn._off || fn);
334
+ if (~i) callbacks.splice(i, 1);
335
+ return this;
336
+ };
337
+
338
+ /**
339
+ * Emit `event` with the given args.
340
+ *
341
+ * @param {String} event
342
+ * @param {Mixed} ...
343
+ * @return {Emitter}
344
+ */
345
+
346
+ Emitter.prototype.emit = function(event){
347
+ this._callbacks = this._callbacks || {};
348
+ var args = [].slice.call(arguments, 1)
349
+ , callbacks = this._callbacks[event];
350
+
351
+ if (callbacks) {
352
+ callbacks = callbacks.slice(0);
353
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
354
+ callbacks[i].apply(this, args);
355
+ }
356
+ }
357
+
358
+ return this;
359
+ };
360
+
361
+ /**
362
+ * Return array of callbacks for `event`.
363
+ *
364
+ * @param {String} event
365
+ * @return {Array}
366
+ * @api public
367
+ */
368
+
369
+ Emitter.prototype.listeners = function(event){
370
+ this._callbacks = this._callbacks || {};
371
+ return this._callbacks[event] || [];
372
+ };
373
+
374
+ /**
375
+ * Check if this emitter has `event` handlers.
376
+ *
377
+ * @param {String} event
378
+ * @return {Boolean}
379
+ * @api public
380
+ */
381
+
382
+ Emitter.prototype.hasListeners = function(event){
383
+ return !! this.listeners(event).length;
384
+ };
385
+
386
+ });
387
+ require.register("node-melo-melo-protocol/lib/protocol.js", function(exports, require, module){
388
+ (function (exports, ByteArray, global) {
389
+ var Protocol = exports;
390
+
391
+ var PKG_HEAD_BYTES = 4;
392
+ var MSG_FLAG_BYTES = 1;
393
+ var MSG_ROUTE_CODE_BYTES = 2;
394
+ var MSG_ID_MAX_BYTES = 5;
395
+ var MSG_ROUTE_LEN_BYTES = 1;
396
+
397
+ var MSG_ROUTE_CODE_MAX = 0xffff;
398
+
399
+ var MSG_COMPRESS_ROUTE_MASK = 0x1;
400
+ var MSG_TYPE_MASK = 0x7;
401
+
402
+ var Package = Protocol.Package = {};
403
+ var Message = Protocol.Message = {};
404
+
405
+ Package.TYPE_HANDSHAKE = 1;
406
+ Package.TYPE_HANDSHAKE_ACK = 2;
407
+ Package.TYPE_HEARTBEAT = 3;
408
+ Package.TYPE_DATA = 4;
409
+ Package.TYPE_KICK = 5;
410
+
411
+ Message.TYPE_REQUEST = 0;
412
+ Message.TYPE_NOTIFY = 1;
413
+ Message.TYPE_RESPONSE = 2;
414
+ Message.TYPE_PUSH = 3;
415
+
416
+ /**
417
+ * pomele client encode
418
+ * id message id;
419
+ * route message route
420
+ * msg message body
421
+ * socketio current support string
422
+ */
423
+ Protocol.strencode = function(str) {
424
+ var byteArray = new ByteArray(str.length * 3);
425
+ var offset = 0;
426
+ for(var i = 0; i < str.length; i++){
427
+ var charCode = str.charCodeAt(i);
428
+ var codes = null;
429
+ if(charCode <= 0x7f){
430
+ codes = [charCode];
431
+ }else if(charCode <= 0x7ff){
432
+ codes = [0xc0|(charCode>>6), 0x80|(charCode & 0x3f)];
433
+ }else{
434
+ codes = [0xe0|(charCode>>12), 0x80|((charCode & 0xfc0)>>6), 0x80|(charCode & 0x3f)];
435
+ }
436
+ for(var j = 0; j < codes.length; j++){
437
+ byteArray[offset] = codes[j];
438
+ ++offset;
439
+ }
440
+ }
441
+ var _buffer = new ByteArray(offset);
442
+ copyArray(_buffer, 0, byteArray, 0, offset);
443
+ return _buffer;
444
+ };
445
+
446
+ /**
447
+ * client decode
448
+ * msg String data
449
+ * return Message Object
450
+ */
451
+ Protocol.strdecode = function(buffer) {
452
+ var bytes = new ByteArray(buffer);
453
+ var array = [];
454
+ var offset = 0;
455
+ var charCode = 0;
456
+ var end = bytes.length;
457
+ while(offset < end){
458
+ if(bytes[offset] < 128){
459
+ charCode = bytes[offset];
460
+ offset += 1;
461
+ }else if(bytes[offset] < 224){
462
+ charCode = ((bytes[offset] & 0x3f)<<6) + (bytes[offset+1] & 0x3f);
463
+ offset += 2;
464
+ }else{
465
+ charCode = ((bytes[offset] & 0x0f)<<12) + ((bytes[offset+1] & 0x3f)<<6) + (bytes[offset+2] & 0x3f);
466
+ offset += 3;
467
+ }
468
+ array.push(charCode);
469
+ }
470
+ var res = '';
471
+ var chunk = 8 * 1024;
472
+ var i;
473
+ for (i = 0; i < array.length / chunk; i++) {
474
+ res += String.fromCharCode.apply(null, array.slice(i * chunk, (i + 1) * chunk));
475
+ }
476
+ res += String.fromCharCode.apply(null, array.slice(i * chunk));
477
+ return res;
478
+ };
479
+
480
+ /**
481
+ * Package protocol encode.
482
+ *
483
+ * Melo package format:
484
+ * +------+-------------+------------------+
485
+ * | type | body length | body |
486
+ * +------+-------------+------------------+
487
+ *
488
+ * Head: 4bytes
489
+ * 0: package type,
490
+ * 1 - handshake,
491
+ * 2 - handshake ack,
492
+ * 3 - heartbeat,
493
+ * 4 - data
494
+ * 5 - kick
495
+ * 1 - 3: big-endian body length
496
+ * Body: body length bytes
497
+ *
498
+ * @param {Number} type package type
499
+ * @param {ByteArray} body body content in bytes
500
+ * @return {ByteArray} new byte array that contains encode result
501
+ */
502
+ Package.encode = function(type, body){
503
+ var length = body ? body.length : 0;
504
+ var buffer = new ByteArray(PKG_HEAD_BYTES + length);
505
+ var index = 0;
506
+ buffer[index++] = type & 0xff;
507
+ buffer[index++] = (length >> 16) & 0xff;
508
+ buffer[index++] = (length >> 8) & 0xff;
509
+ buffer[index++] = length & 0xff;
510
+ if(body) {
511
+ copyArray(buffer, index, body, 0, length);
512
+ }
513
+ return buffer;
514
+ };
515
+
516
+ /**
517
+ * Package protocol decode.
518
+ * See encode for package format.
519
+ *
520
+ * @param {ByteArray} buffer byte array containing package content
521
+ * @return {Object} {type: package type, buffer: body byte array}
522
+ */
523
+ Package.decode = function(buffer){
524
+ var bytes = new ByteArray(buffer);
525
+ var type = bytes[0];
526
+ var index = 1;
527
+ var length = ((bytes[index++]) << 16 | (bytes[index++]) << 8 | bytes[index++]) >>> 0;
528
+ var body = length ? new ByteArray(length) : null;
529
+ copyArray(body, 0, bytes, PKG_HEAD_BYTES, length);
530
+ return {'type': type, 'body': body};
531
+ };
532
+
533
+ /**
534
+ * Message protocol encode.
535
+ *
536
+ * @param {Number} id message id
537
+ * @param {Number} type message type
538
+ * @param {Number} compressRoute whether compress route
539
+ * @param {Number|String} route route code or route string
540
+ * @param {Buffer} msg message body bytes
541
+ * @return {Buffer} encode result
542
+ */
543
+ Message.encode = function(id, type, compressRoute, route, msg){
544
+ // caculate message max length
545
+ var idBytes = msgHasId(type) ? caculateMsgIdBytes(id) : 0;
546
+ var msgLen = MSG_FLAG_BYTES + idBytes;
547
+
548
+ if(msgHasRoute(type)) {
549
+ if(compressRoute) {
550
+ if(typeof route !== 'number'){
551
+ throw new Error('error flag for number route!');
552
+ }
553
+ msgLen += MSG_ROUTE_CODE_BYTES;
554
+ } else {
555
+ msgLen += MSG_ROUTE_LEN_BYTES;
556
+ if(route) {
557
+ route = Protocol.strencode(route);
558
+ if(route.length>255) {
559
+ throw new Error('route maxlength is overflow');
560
+ }
561
+ msgLen += route.length;
562
+ }
563
+ }
564
+ }
565
+
566
+ if(msg) {
567
+ msgLen += msg.length;
568
+ }
569
+
570
+ var buffer = new ByteArray(msgLen);
571
+ var offset = 0;
572
+
573
+ // add flag
574
+ offset = encodeMsgFlag(type, compressRoute, buffer, offset);
575
+
576
+ // add message id
577
+ if(msgHasId(type)) {
578
+ offset = encodeMsgId(id, idBytes, buffer, offset);
579
+ }
580
+
581
+ // add route
582
+ if(msgHasRoute(type)) {
583
+ offset = encodeMsgRoute(compressRoute, route, buffer, offset);
584
+ }
585
+
586
+ // add body
587
+ if(msg) {
588
+ offset = encodeMsgBody(msg, buffer, offset);
589
+ }
590
+
591
+ return buffer;
592
+ };
593
+
594
+ /**
595
+ * Message protocol decode.
596
+ *
597
+ * @param {Buffer|Uint8Array} buffer message bytes
598
+ * @return {Object} message object
599
+ */
600
+ Message.decode = function(buffer) {
601
+ var bytes = new ByteArray(buffer);
602
+ var bytesLen = bytes.length || bytes.byteLength;
603
+ var offset = 0;
604
+ var id = 0;
605
+ var route = null;
606
+
607
+ // parse flag
608
+ var flag = bytes[offset++];
609
+ var compressRoute = flag & MSG_COMPRESS_ROUTE_MASK;
610
+ var type = (flag >> 1) & MSG_TYPE_MASK;
611
+
612
+ // parse id
613
+ if(msgHasId(type)) {
614
+ var byte = bytes[offset++];
615
+ id = byte & 0x7f;
616
+ while(byte & 0x80) {
617
+ id <<= 7;
618
+ byte = bytes[offset++];
619
+ id |= byte & 0x7f;
620
+ }
621
+ }
622
+
623
+ // parse route
624
+ if(msgHasRoute(type)) {
625
+ if(compressRoute) {
626
+ route = (bytes[offset++]) << 8 | bytes[offset++];
627
+ } else {
628
+ var routeLen = bytes[offset++];
629
+ if(routeLen) {
630
+ route = new ByteArray(routeLen);
631
+ copyArray(route, 0, bytes, offset, routeLen);
632
+ route = Protocol.strdecode(route);
633
+ } else {
634
+ route = '';
635
+ }
636
+ offset += routeLen;
637
+ }
638
+ }
639
+
640
+ // parse body
641
+ var bodyLen = bytesLen - offset;
642
+ var body = new ByteArray(bodyLen);
643
+
644
+ copyArray(body, 0, bytes, offset, bodyLen);
645
+
646
+ return {'id': id, 'type': type, 'compressRoute': compressRoute,
647
+ 'route': route, 'body': body};
648
+ };
649
+
650
+ var copyArray = function(dest, doffset, src, soffset, length) {
651
+ if('function' === typeof src.copy) {
652
+ // Buffer
653
+ src.copy(dest, doffset, soffset, soffset + length);
654
+ } else {
655
+ // Uint8Array
656
+ for(var index=0; index<length; index++){
657
+ dest[doffset++] = src[soffset++];
658
+ }
659
+ }
660
+ };
661
+
662
+ var msgHasId = function(type) {
663
+ return type === Message.TYPE_REQUEST || type === Message.TYPE_RESPONSE;
664
+ };
665
+
666
+ var msgHasRoute = function(type) {
667
+ return type === Message.TYPE_REQUEST || type === Message.TYPE_NOTIFY ||
668
+ type === Message.TYPE_PUSH;
669
+ };
670
+
671
+ var caculateMsgIdBytes = function(id) {
672
+ var len = 0;
673
+ do {
674
+ len += 1;
675
+ id >>= 7;
676
+ } while(id > 0);
677
+ return len;
678
+ };
679
+
680
+ var encodeMsgFlag = function(type, compressRoute, buffer, offset) {
681
+ if(type !== Message.TYPE_REQUEST && type !== Message.TYPE_NOTIFY &&
682
+ type !== Message.TYPE_RESPONSE && type !== Message.TYPE_PUSH) {
683
+ throw new Error('unkonw message type: ' + type);
684
+ }
685
+
686
+ buffer[offset] = (type << 1) | (compressRoute ? 1 : 0);
687
+
688
+ return offset + MSG_FLAG_BYTES;
689
+ };
690
+
691
+ var encodeMsgId = function(id, idBytes, buffer, offset) {
692
+ var index = offset + idBytes - 1;
693
+ buffer[index--] = id & 0x7f;
694
+ while(index >= offset) {
695
+ id >>= 7;
696
+ buffer[index--] = id & 0x7f | 0x80;
697
+ }
698
+ return offset + idBytes;
699
+ };
700
+
701
+ var encodeMsgRoute = function(compressRoute, route, buffer, offset) {
702
+ if (compressRoute) {
703
+ if(route > MSG_ROUTE_CODE_MAX){
704
+ throw new Error('route number is overflow');
705
+ }
706
+
707
+ buffer[offset++] = (route >> 8) & 0xff;
708
+ buffer[offset++] = route & 0xff;
709
+ } else {
710
+ if(route) {
711
+ buffer[offset++] = route.length & 0xff;
712
+ copyArray(buffer, offset, route, 0, route.length);
713
+ offset += route.length;
714
+ } else {
715
+ buffer[offset++] = 0;
716
+ }
717
+ }
718
+
719
+ return offset;
720
+ };
721
+
722
+ var encodeMsgBody = function(msg, buffer, offset) {
723
+ copyArray(buffer, offset, msg, 0, msg.length);
724
+ return offset + msg.length;
725
+ };
726
+
727
+ module.exports = Protocol;
728
+ })('object' === typeof module ? module.exports : (this.Protocol = {}),'object' === typeof module ? Buffer : Uint8Array, this);
729
+
730
+ });
731
+ require.register("melonode-melo-protobuf/lib/client/protobuf.js", function(exports, require, module){
732
+ /* ProtocolBuffer client 0.1.0*/
733
+
734
+ /**
735
+ * melo-protobuf
736
+ * @author <zhang0935@gmail.com>
737
+ */
738
+
739
+ /**
740
+ * Protocol buffer root
741
+ * In browser, it will be window.protbuf
742
+ */
743
+ (function (exports, global){
744
+ var Protobuf = exports;
745
+
746
+ Protobuf.init = function(opts){
747
+ //On the serverside, use serverProtos to encode messages send to client
748
+ Protobuf.encoder.init(opts.encoderProtos);
749
+
750
+ //On the serverside, user clientProtos to decode messages receive from clients
751
+ Protobuf.decoder.init(opts.decoderProtos);
752
+ };
753
+
754
+ Protobuf.encode = function(key, msg){
755
+ return Protobuf.encoder.encode(key, msg);
756
+ };
757
+
758
+ Protobuf.decode = function(key, msg){
759
+ return Protobuf.decoder.decode(key, msg);
760
+ };
761
+
762
+ // exports to support for components
763
+ module.exports = Protobuf;
764
+ })('object' === typeof module ? module.exports : (this.protobuf = {}), this);
765
+
766
+ /**
767
+ * constants
768
+ */
769
+ (function (exports, global){
770
+ var constants = exports.constants = {};
771
+
772
+ constants.TYPES = {
773
+ uInt32 : 0,
774
+ sInt32 : 0,
775
+ int32 : 0,
776
+ double : 1,
777
+ string : 2,
778
+ message : 2,
779
+ float : 5
780
+ };
781
+
782
+ })('undefined' !== typeof protobuf ? protobuf : module.exports, this);
783
+
784
+ /**
785
+ * util module
786
+ */
787
+ (function (exports, global){
788
+
789
+ var Util = exports.util = {};
790
+
791
+ Util.isSimpleType = function(type){
792
+ return ( type === 'uInt32' ||
793
+ type === 'sInt32' ||
794
+ type === 'int32' ||
795
+ type === 'uInt64' ||
796
+ type === 'sInt64' ||
797
+ type === 'float' ||
798
+ type === 'double' );
799
+ };
800
+
801
+ })('undefined' !== typeof protobuf ? protobuf : module.exports, this);
802
+
803
+ /**
804
+ * codec module
805
+ */
806
+ (function (exports, global){
807
+
808
+ var Codec = exports.codec = {};
809
+
810
+ var buffer = new ArrayBuffer(8);
811
+ var float32Array = new Float32Array(buffer);
812
+ var float64Array = new Float64Array(buffer);
813
+ var uInt8Array = new Uint8Array(buffer);
814
+
815
+ Codec.encodeUInt32 = function(n){
816
+ var n = parseInt(n);
817
+ if(isNaN(n) || n < 0){
818
+ return null;
819
+ }
820
+
821
+ var result = [];
822
+ do{
823
+ var tmp = n % 128;
824
+ var next = Math.floor(n/128);
825
+
826
+ if(next !== 0){
827
+ tmp = tmp + 128;
828
+ }
829
+ result.push(tmp);
830
+ n = next;
831
+ }while(n !== 0);
832
+
833
+ return result;
834
+ };
835
+
836
+ Codec.encodeSInt32 = function(n){
837
+ var n = parseInt(n);
838
+ if(isNaN(n)){
839
+ return null;
840
+ }
841
+ n = n<0?(Math.abs(n)*2-1):n*2;
842
+
843
+ return Codec.encodeUInt32(n);
844
+ };
845
+
846
+ Codec.decodeUInt32 = function(bytes){
847
+ var n = 0;
848
+
849
+ for(var i = 0; i < bytes.length; i++){
850
+ var m = parseInt(bytes[i]);
851
+ n = n + ((m & 0x7f) * Math.pow(2,(7*i)));
852
+ if(m < 128){
853
+ return n;
854
+ }
855
+ }
856
+
857
+ return n;
858
+ };
859
+
860
+
861
+ Codec.decodeSInt32 = function(bytes){
862
+ var n = this.decodeUInt32(bytes);
863
+ var flag = ((n%2) === 1)?-1:1;
864
+
865
+ n = ((n%2 + n)/2)*flag;
866
+
867
+ return n;
868
+ };
869
+
870
+ Codec.encodeFloat = function(float){
871
+ float32Array[0] = float;
872
+ return uInt8Array;
873
+ };
874
+
875
+ Codec.decodeFloat = function(bytes, offset){
876
+ if(!bytes || bytes.length < (offset +4)){
877
+ return null;
878
+ }
879
+
880
+ for(var i = 0; i < 4; i++){
881
+ uInt8Array[i] = bytes[offset + i];
882
+ }
883
+
884
+ return float32Array[0];
885
+ };
886
+
887
+ Codec.encodeDouble = function(double){
888
+ float64Array[0] = double;
889
+ return uInt8Array.subarray(0, 8);
890
+ };
891
+
892
+ Codec.decodeDouble = function(bytes, offset){
893
+ if(!bytes || bytes.length < (8 + offset)){
894
+ return null;
895
+ }
896
+
897
+ for(var i = 0; i < 8; i++){
898
+ uInt8Array[i] = bytes[offset + i];
899
+ }
900
+
901
+ return float64Array[0];
902
+ };
903
+
904
+ Codec.encodeStr = function(bytes, offset, str){
905
+ for(var i = 0; i < str.length; i++){
906
+ var code = str.charCodeAt(i);
907
+ var codes = encode2UTF8(code);
908
+
909
+ for(var j = 0; j < codes.length; j++){
910
+ bytes[offset] = codes[j];
911
+ offset++;
912
+ }
913
+ }
914
+
915
+ return offset;
916
+ };
917
+
918
+ /**
919
+ * Decode string from utf8 bytes
920
+ */
921
+ Codec.decodeStr = function(bytes, offset, length){
922
+ var array = [];
923
+ var end = offset + length;
924
+
925
+ while(offset < end){
926
+ var code = 0;
927
+
928
+ if(bytes[offset] < 128){
929
+ code = bytes[offset];
930
+
931
+ offset += 1;
932
+ }else if(bytes[offset] < 224){
933
+ code = ((bytes[offset] & 0x3f)<<6) + (bytes[offset+1] & 0x3f);
934
+ offset += 2;
935
+ }else{
936
+ code = ((bytes[offset] & 0x0f)<<12) + ((bytes[offset+1] & 0x3f)<<6) + (bytes[offset+2] & 0x3f);
937
+ offset += 3;
938
+ }
939
+
940
+ array.push(code);
941
+
942
+ }
943
+
944
+ var str = '';
945
+ for(var i = 0; i < array.length;){
946
+ str += String.fromCharCode.apply(null, array.slice(i, i + 10000));
947
+ i += 10000;
948
+ }
949
+
950
+ return str;
951
+ };
952
+
953
+ /**
954
+ * Return the byte length of the str use utf8
955
+ */
956
+ Codec.byteLength = function(str){
957
+ if(typeof(str) !== 'string'){
958
+ return -1;
959
+ }
960
+
961
+ var length = 0;
962
+
963
+ for(var i = 0; i < str.length; i++){
964
+ var code = str.charCodeAt(i);
965
+ length += codeLength(code);
966
+ }
967
+
968
+ return length;
969
+ };
970
+
971
+ /**
972
+ * Encode a unicode16 char code to utf8 bytes
973
+ */
974
+ function encode2UTF8(charCode){
975
+ if(charCode <= 0x7f){
976
+ return [charCode];
977
+ }else if(charCode <= 0x7ff){
978
+ return [0xc0|(charCode>>6), 0x80|(charCode & 0x3f)];
979
+ }else{
980
+ return [0xe0|(charCode>>12), 0x80|((charCode & 0xfc0)>>6), 0x80|(charCode & 0x3f)];
981
+ }
982
+ }
983
+
984
+ function codeLength(code){
985
+ if(code <= 0x7f){
986
+ return 1;
987
+ }else if(code <= 0x7ff){
988
+ return 2;
989
+ }else{
990
+ return 3;
991
+ }
992
+ }
993
+ })('undefined' !== typeof protobuf ? protobuf : module.exports, this);
994
+
995
+ /**
996
+ * encoder module
997
+ */
998
+ (function (exports, global){
999
+
1000
+ var protobuf = exports;
1001
+ var MsgEncoder = exports.encoder = {};
1002
+
1003
+ var codec = protobuf.codec;
1004
+ var constant = protobuf.constants;
1005
+ var util = protobuf.util;
1006
+
1007
+ MsgEncoder.init = function(protos){
1008
+ this.protos = protos || {};
1009
+ };
1010
+
1011
+ MsgEncoder.encode = function(route, msg){
1012
+ //Get protos from protos map use the route as key
1013
+ var protos = this.protos[route];
1014
+
1015
+ //Check msg
1016
+ if(!checkMsg(msg, protos)){
1017
+ return null;
1018
+ }
1019
+
1020
+ //Set the length of the buffer 2 times bigger to prevent overflow
1021
+ var length = codec.byteLength(JSON.stringify(msg));
1022
+
1023
+ //Init buffer and offset
1024
+ var buffer = new ArrayBuffer(length);
1025
+ var uInt8Array = new Uint8Array(buffer);
1026
+ var offset = 0;
1027
+
1028
+ if(!!protos){
1029
+ offset = encodeMsg(uInt8Array, offset, protos, msg);
1030
+ if(offset > 0){
1031
+ return uInt8Array.subarray(0, offset);
1032
+ }
1033
+ }
1034
+
1035
+ return null;
1036
+ };
1037
+
1038
+ /**
1039
+ * Check if the msg follow the defination in the protos
1040
+ */
1041
+ function checkMsg(msg, protos){
1042
+ if(!protos){
1043
+ return false;
1044
+ }
1045
+
1046
+ for(var name in protos){
1047
+ var proto = protos[name];
1048
+
1049
+ //All required element must exist
1050
+ switch(proto.option){
1051
+ case 'required' :
1052
+ if(typeof(msg[name]) === 'undefined'){
1053
+ return false;
1054
+ }
1055
+ case 'optional' :
1056
+ if(typeof(msg[name]) !== 'undefined'){
1057
+ if(!!protos.__messages[proto.type]){
1058
+ checkMsg(msg[name], protos.__messages[proto.type]);
1059
+ }
1060
+ }
1061
+ break;
1062
+ case 'repeated' :
1063
+ //Check nest message in repeated elements
1064
+ if(!!msg[name] && !!protos.__messages[proto.type]){
1065
+ for(var i = 0; i < msg[name].length; i++){
1066
+ if(!checkMsg(msg[name][i], protos.__messages[proto.type])){
1067
+ return false;
1068
+ }
1069
+ }
1070
+ }
1071
+ break;
1072
+ }
1073
+ }
1074
+
1075
+ return true;
1076
+ }
1077
+
1078
+ function encodeMsg(buffer, offset, protos, msg){
1079
+ for(var name in msg){
1080
+ if(!!protos[name]){
1081
+ var proto = protos[name];
1082
+
1083
+ switch(proto.option){
1084
+ case 'required' :
1085
+ case 'optional' :
1086
+ offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
1087
+ offset = encodeProp(msg[name], proto.type, offset, buffer, protos);
1088
+ break;
1089
+ case 'repeated' :
1090
+ if(msg[name].length > 0){
1091
+ offset = encodeArray(msg[name], proto, offset, buffer, protos);
1092
+ }
1093
+ break;
1094
+ }
1095
+ }
1096
+ }
1097
+
1098
+ return offset;
1099
+ }
1100
+
1101
+ function encodeProp(value, type, offset, buffer, protos){
1102
+ switch(type){
1103
+ case 'uInt32':
1104
+ offset = writeBytes(buffer, offset, codec.encodeUInt32(value));
1105
+ break;
1106
+ case 'int32' :
1107
+ case 'sInt32':
1108
+ offset = writeBytes(buffer, offset, codec.encodeSInt32(value));
1109
+ break;
1110
+ case 'float':
1111
+ writeBytes(buffer, offset, codec.encodeFloat(value));
1112
+ offset += 4;
1113
+ break;
1114
+ case 'double':
1115
+ writeBytes(buffer, offset, codec.encodeDouble(value));
1116
+ offset += 8;
1117
+ break;
1118
+ case 'string':
1119
+ var length = codec.byteLength(value);
1120
+
1121
+ //Encode length
1122
+ offset = writeBytes(buffer, offset, codec.encodeUInt32(length));
1123
+ //write string
1124
+ codec.encodeStr(buffer, offset, value);
1125
+ offset += length;
1126
+ break;
1127
+ default :
1128
+ if(!!protos.__messages[type]){
1129
+ //Use a tmp buffer to build an internal msg
1130
+ var tmpBuffer = new ArrayBuffer(codec.byteLength(JSON.stringify(value)));
1131
+ var length = 0;
1132
+
1133
+ length = encodeMsg(tmpBuffer, length, protos.__messages[type], value);
1134
+ //Encode length
1135
+ offset = writeBytes(buffer, offset, codec.encodeUInt32(length));
1136
+ //contact the object
1137
+ for(var i = 0; i < length; i++){
1138
+ buffer[offset] = tmpBuffer[i];
1139
+ offset++;
1140
+ }
1141
+ }
1142
+ break;
1143
+ }
1144
+
1145
+ return offset;
1146
+ }
1147
+
1148
+ /**
1149
+ * Encode reapeated properties, simple msg and object are decode differented
1150
+ */
1151
+ function encodeArray(array, proto, offset, buffer, protos){
1152
+ var i = 0;
1153
+
1154
+ if(util.isSimpleType(proto.type)){
1155
+ offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
1156
+ offset = writeBytes(buffer, offset, codec.encodeUInt32(array.length));
1157
+ for(i = 0; i < array.length; i++){
1158
+ offset = encodeProp(array[i], proto.type, offset, buffer);
1159
+ }
1160
+ }else{
1161
+ for(i = 0; i < array.length; i++){
1162
+ offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
1163
+ offset = encodeProp(array[i], proto.type, offset, buffer, protos);
1164
+ }
1165
+ }
1166
+
1167
+ return offset;
1168
+ }
1169
+
1170
+ function writeBytes(buffer, offset, bytes){
1171
+ for(var i = 0; i < bytes.length; i++, offset++){
1172
+ buffer[offset] = bytes[i];
1173
+ }
1174
+
1175
+ return offset;
1176
+ }
1177
+
1178
+ function encodeTag(type, tag){
1179
+ var value = constant.TYPES[type]||2;
1180
+ return codec.encodeUInt32((tag<<3)|value);
1181
+ }
1182
+ })('undefined' !== typeof protobuf ? protobuf : module.exports, this);
1183
+
1184
+ /**
1185
+ * decoder module
1186
+ */
1187
+ (function (exports, global){
1188
+ var protobuf = exports;
1189
+ var MsgDecoder = exports.decoder = {};
1190
+
1191
+ var codec = protobuf.codec;
1192
+ var util = protobuf.util;
1193
+
1194
+ var buffer;
1195
+ var offset = 0;
1196
+
1197
+ MsgDecoder.init = function(protos){
1198
+ this.protos = protos || {};
1199
+ };
1200
+
1201
+ MsgDecoder.setProtos = function(protos){
1202
+ if(!!protos){
1203
+ this.protos = protos;
1204
+ }
1205
+ };
1206
+
1207
+ MsgDecoder.decode = function(route, buf){
1208
+ var protos = this.protos[route];
1209
+
1210
+ buffer = buf;
1211
+ offset = 0;
1212
+
1213
+ if(!!protos){
1214
+ return decodeMsg({}, protos, buffer.length);
1215
+ }
1216
+
1217
+ return null;
1218
+ };
1219
+
1220
+ function decodeMsg(msg, protos, length){
1221
+ while(offset<length){
1222
+ var head = getHead();
1223
+ var type = head.type;
1224
+ var tag = head.tag;
1225
+ var name = protos.__tags[tag];
1226
+
1227
+ switch(protos[name].option){
1228
+ case 'optional' :
1229
+ case 'required' :
1230
+ msg[name] = decodeProp(protos[name].type, protos);
1231
+ break;
1232
+ case 'repeated' :
1233
+ if(!msg[name]){
1234
+ msg[name] = [];
1235
+ }
1236
+ decodeArray(msg[name], protos[name].type, protos);
1237
+ break;
1238
+ }
1239
+ }
1240
+
1241
+ return msg;
1242
+ }
1243
+
1244
+ /**
1245
+ * Test if the given msg is finished
1246
+ */
1247
+ function isFinish(msg, protos){
1248
+ return (!protos.__tags[peekHead().tag]);
1249
+ }
1250
+ /**
1251
+ * Get property head from protobuf
1252
+ */
1253
+ function getHead(){
1254
+ var tag = codec.decodeUInt32(getBytes());
1255
+
1256
+ return {
1257
+ type : tag&0x7,
1258
+ tag : tag>>3
1259
+ };
1260
+ }
1261
+
1262
+ /**
1263
+ * Get tag head without move the offset
1264
+ */
1265
+ function peekHead(){
1266
+ var tag = codec.decodeUInt32(peekBytes());
1267
+
1268
+ return {
1269
+ type : tag&0x7,
1270
+ tag : tag>>3
1271
+ };
1272
+ }
1273
+
1274
+ function decodeProp(type, protos){
1275
+ switch(type){
1276
+ case 'uInt32':
1277
+ return codec.decodeUInt32(getBytes());
1278
+ case 'int32' :
1279
+ case 'sInt32' :
1280
+ return codec.decodeSInt32(getBytes());
1281
+ case 'float' :
1282
+ var float = codec.decodeFloat(buffer, offset);
1283
+ offset += 4;
1284
+ return float;
1285
+ case 'double' :
1286
+ var double = codec.decodeDouble(buffer, offset);
1287
+ offset += 8;
1288
+ return double;
1289
+ case 'string' :
1290
+ var length = codec.decodeUInt32(getBytes());
1291
+
1292
+ var str = codec.decodeStr(buffer, offset, length);
1293
+ offset += length;
1294
+
1295
+ return str;
1296
+ default :
1297
+ if(!!protos && !!protos.__messages[type]){
1298
+ var length = codec.decodeUInt32(getBytes());
1299
+ var msg = {};
1300
+ decodeMsg(msg, protos.__messages[type], offset+length);
1301
+ return msg;
1302
+ }
1303
+ break;
1304
+ }
1305
+ }
1306
+
1307
+ function decodeArray(array, type, protos){
1308
+ if(util.isSimpleType(type)){
1309
+ var length = codec.decodeUInt32(getBytes());
1310
+
1311
+ for(var i = 0; i < length; i++){
1312
+ array.push(decodeProp(type));
1313
+ }
1314
+ }else{
1315
+ array.push(decodeProp(type, protos));
1316
+ }
1317
+ }
1318
+
1319
+ function getBytes(flag){
1320
+ var bytes = [];
1321
+ var pos = offset;
1322
+ flag = flag || false;
1323
+
1324
+ var b;
1325
+
1326
+ do{
1327
+ b = buffer[pos];
1328
+ bytes.push(b);
1329
+ pos++;
1330
+ }while(b >= 128);
1331
+
1332
+ if(!flag){
1333
+ offset = pos;
1334
+ }
1335
+ return bytes;
1336
+ }
1337
+
1338
+ function peekBytes(){
1339
+ return getBytes(true);
1340
+ }
1341
+
1342
+ })('undefined' !== typeof protobuf ? protobuf : module.exports, this);
1343
+
1344
+
1345
+ });
1346
+ require.register("pinusnode-pinus-jsclient-websocket/lib/melo-client.js", function(exports, require, module){
1347
+ (function() {
1348
+ var JS_WS_CLIENT_TYPE = 'js-websocket';
1349
+ var JS_WS_CLIENT_VERSION = '0.0.1';
1350
+
1351
+ var Protocol = window.Protocol;
1352
+ var Package = Protocol.Package;
1353
+ var Message = Protocol.Message;
1354
+ var EventEmitter = window.EventEmitter;
1355
+
1356
+ var RES_OK = 200;
1357
+ var RES_FAIL = 500;
1358
+ var RES_OLD_CLIENT = 501;
1359
+
1360
+ if (typeof Object.create !== 'function') {
1361
+ Object.create = function (o) {
1362
+ function F() {}
1363
+ F.prototype = o;
1364
+ return new F();
1365
+ };
1366
+ }
1367
+
1368
+ var root = window;
1369
+ var melo = Object.create(EventEmitter.prototype); // object extend from object
1370
+ root.melo = melo;
1371
+ var socket = null;
1372
+ var reqId = 0;
1373
+ var callbacks = {};
1374
+ var handlers = {};
1375
+ //Map from request id to route
1376
+ var routeMap = {};
1377
+
1378
+ var heartbeatInterval = 0;
1379
+ var heartbeatTimeout = 0;
1380
+ var nextHeartbeatTimeout = 0;
1381
+ var gapThreshold = 100; // heartbeat gap threashold
1382
+ var heartbeatId = null;
1383
+ var heartbeatTimeoutId = null;
1384
+
1385
+ var handshakeCallback = null;
1386
+
1387
+ var handshakeBuffer = {
1388
+ 'sys': {
1389
+ type: JS_WS_CLIENT_TYPE,
1390
+ version: JS_WS_CLIENT_VERSION
1391
+ },
1392
+ 'user': {
1393
+ }
1394
+ };
1395
+
1396
+ var initCallback = null;
1397
+
1398
+ melo.init = function(params, cb){
1399
+ initCallback = cb;
1400
+ var host = params.host;
1401
+ var port = params.port;
1402
+
1403
+ var url = 'ws://' + host;
1404
+ if(port) {
1405
+ url += ':' + port;
1406
+ }
1407
+
1408
+ handshakeBuffer.user = params.user;
1409
+ handshakeCallback = params.handshakeCallback;
1410
+ initWebSocket(url, cb);
1411
+ };
1412
+
1413
+ var initWebSocket = function(url,cb) {
1414
+ console.log('connect to ' + url);
1415
+ var onopen = function(event){
1416
+ var obj = Package.encode(Package.TYPE_HANDSHAKE, Protocol.strencode(JSON.stringify(handshakeBuffer)));
1417
+ send(obj);
1418
+ };
1419
+ var onmessage = function(event) {
1420
+ processPackage(Package.decode(event.data), cb);
1421
+ // new package arrived, update the heartbeat timeout
1422
+ if(heartbeatTimeout) {
1423
+ nextHeartbeatTimeout = Date.now() + heartbeatTimeout;
1424
+ }
1425
+ };
1426
+ var onerror = function(event) {
1427
+ melo.emit('io-error', event);
1428
+ console.error('socket error: ', event);
1429
+ };
1430
+ var onclose = function(event){
1431
+ melo.emit('close',event);
1432
+ console.error('socket close: ', event);
1433
+ };
1434
+ socket = new WebSocket(url);
1435
+ socket.binaryType = 'arraybuffer';
1436
+ socket.onopen = onopen;
1437
+ socket.onmessage = onmessage;
1438
+ socket.onerror = onerror;
1439
+ socket.onclose = onclose;
1440
+ };
1441
+
1442
+ melo.disconnect = function() {
1443
+ if(socket) {
1444
+ if(socket.disconnect) socket.disconnect();
1445
+ if(socket.close) socket.close();
1446
+ console.log('disconnect');
1447
+ socket = null;
1448
+ }
1449
+
1450
+ if(heartbeatId) {
1451
+ clearTimeout(heartbeatId);
1452
+ heartbeatId = null;
1453
+ }
1454
+ if(heartbeatTimeoutId) {
1455
+ clearTimeout(heartbeatTimeoutId);
1456
+ heartbeatTimeoutId = null;
1457
+ }
1458
+ };
1459
+
1460
+ melo.request = function(route, msg, cb) {
1461
+ if(arguments.length === 2 && typeof msg === 'function') {
1462
+ cb = msg;
1463
+ msg = {};
1464
+ } else {
1465
+ msg = msg || {};
1466
+ }
1467
+ route = route || msg.route;
1468
+ if(!route) {
1469
+ return;
1470
+ }
1471
+
1472
+ reqId++;
1473
+ sendMessage(reqId, route, msg);
1474
+
1475
+ callbacks[reqId] = cb;
1476
+ routeMap[reqId] = route;
1477
+ };
1478
+
1479
+ melo.notify = function(route, msg) {
1480
+ msg = msg || {};
1481
+ sendMessage(0, route, msg);
1482
+ };
1483
+
1484
+ var sendMessage = function(reqId, route, msg) {
1485
+ var type = reqId ? Message.TYPE_REQUEST : Message.TYPE_NOTIFY;
1486
+
1487
+ //compress message by protobuf
1488
+ var protos = !!melo.data.protos?melo.data.protos.client:{};
1489
+ if(!!protos[route]){
1490
+ msg = protobuf.encode(route, msg);
1491
+ }else{
1492
+ msg = Protocol.strencode(JSON.stringify(msg));
1493
+ }
1494
+
1495
+
1496
+ var compressRoute = 0;
1497
+ if(melo.dict && melo.dict[route]){
1498
+ route = melo.dict[route];
1499
+ compressRoute = 1;
1500
+ }
1501
+
1502
+ msg = Message.encode(reqId, type, compressRoute, route, msg);
1503
+ var packet = Package.encode(Package.TYPE_DATA, msg);
1504
+ send(packet);
1505
+ };
1506
+
1507
+ var send = function(packet){
1508
+ socket.send(packet.buffer);
1509
+ };
1510
+
1511
+
1512
+ var handler = {};
1513
+
1514
+ var heartbeat = function(data) {
1515
+ if(!heartbeatInterval) {
1516
+ // no heartbeat
1517
+ return;
1518
+ }
1519
+
1520
+ var obj = Package.encode(Package.TYPE_HEARTBEAT);
1521
+ if(heartbeatTimeoutId) {
1522
+ clearTimeout(heartbeatTimeoutId);
1523
+ heartbeatTimeoutId = null;
1524
+ }
1525
+
1526
+ if(heartbeatId) {
1527
+ // already in a heartbeat interval
1528
+ return;
1529
+ }
1530
+
1531
+ heartbeatId = setTimeout(function() {
1532
+ heartbeatId = null;
1533
+ send(obj);
1534
+
1535
+ nextHeartbeatTimeout = Date.now() + heartbeatTimeout;
1536
+ heartbeatTimeoutId = setTimeout(heartbeatTimeoutCb, heartbeatTimeout);
1537
+ }, heartbeatInterval);
1538
+ };
1539
+
1540
+ var heartbeatTimeoutCb = function() {
1541
+ var gap = nextHeartbeatTimeout - Date.now();
1542
+ if(gap > gapThreshold) {
1543
+ heartbeatTimeoutId = setTimeout(heartbeatTimeoutCb, gap);
1544
+ } else {
1545
+ console.error('server heartbeat timeout');
1546
+ melo.emit('heartbeat timeout');
1547
+ melo.disconnect();
1548
+ }
1549
+ };
1550
+
1551
+ var handshake = function(data){
1552
+ data = JSON.parse(Protocol.strdecode(data));
1553
+ if(data.code === RES_OLD_CLIENT) {
1554
+ melo.emit('error', 'client version not fullfill');
1555
+ return;
1556
+ }
1557
+
1558
+ if(data.code !== RES_OK) {
1559
+ melo.emit('error', 'handshake fail');
1560
+ return;
1561
+ }
1562
+
1563
+ handshakeInit(data);
1564
+
1565
+ var obj = Package.encode(Package.TYPE_HANDSHAKE_ACK);
1566
+ send(obj);
1567
+ if(initCallback) {
1568
+ initCallback(socket);
1569
+ initCallback = null;
1570
+ }
1571
+ };
1572
+
1573
+ var onData = function(data){
1574
+ //probuff decode
1575
+ var msg = Message.decode(data);
1576
+
1577
+ if(msg.id > 0){
1578
+ msg.route = routeMap[msg.id];
1579
+ delete routeMap[msg.id];
1580
+ if(!msg.route){
1581
+ return;
1582
+ }
1583
+ }
1584
+
1585
+ msg.body = deCompose(msg);
1586
+
1587
+ processMessage(melo, msg);
1588
+ };
1589
+
1590
+ var onKick = function(data) {
1591
+ melo.emit('onKick');
1592
+ };
1593
+
1594
+ handlers[Package.TYPE_HANDSHAKE] = handshake;
1595
+ handlers[Package.TYPE_HEARTBEAT] = heartbeat;
1596
+ handlers[Package.TYPE_DATA] = onData;
1597
+ handlers[Package.TYPE_KICK] = onKick;
1598
+
1599
+ var processPackage = function(msg) {
1600
+ handlers[msg.type](msg.body);
1601
+ };
1602
+
1603
+ var processMessage = function(melo, msg) {
1604
+ if(!msg.id) {
1605
+ // server push message
1606
+ melo.emit(msg.route, msg.body);
1607
+ return;
1608
+ }
1609
+
1610
+ //if have a id then find the callback function with the request
1611
+ var cb = callbacks[msg.id];
1612
+
1613
+ delete callbacks[msg.id];
1614
+ if(typeof cb !== 'function') {
1615
+ return;
1616
+ }
1617
+
1618
+ cb(msg.body);
1619
+ return;
1620
+ };
1621
+
1622
+ var processMessageBatch = function(melo, msgs) {
1623
+ for(var i=0, l=msgs.length; i<l; i++) {
1624
+ processMessage(melo, msgs[i]);
1625
+ }
1626
+ };
1627
+
1628
+ var deCompose = function(msg){
1629
+ var protos = !!melo.data.protos?melo.data.protos.server:{};
1630
+ var abbrs = melo.data.abbrs;
1631
+ var route = msg.route;
1632
+
1633
+ //Decompose route from dict
1634
+ if(msg.compressRoute) {
1635
+ if(!abbrs[route]){
1636
+ return {};
1637
+ }
1638
+
1639
+ route = msg.route = abbrs[route];
1640
+ }
1641
+ if(!!protos[route]){
1642
+ return protobuf.decode(route, msg.body);
1643
+ }else{
1644
+ return JSON.parse(Protocol.strdecode(msg.body));
1645
+ }
1646
+
1647
+ return msg;
1648
+ };
1649
+
1650
+ var handshakeInit = function(data){
1651
+ if(data.sys && data.sys.heartbeat) {
1652
+ heartbeatInterval = data.sys.heartbeat * 1000; // heartbeat interval
1653
+ heartbeatTimeout = heartbeatInterval * 2; // max heartbeat timeout
1654
+ } else {
1655
+ heartbeatInterval = 0;
1656
+ heartbeatTimeout = 0;
1657
+ }
1658
+
1659
+ initData(data);
1660
+
1661
+ if(typeof handshakeCallback === 'function') {
1662
+ handshakeCallback(data.user);
1663
+ }
1664
+ };
1665
+
1666
+ //Initilize data used in melo client
1667
+ var initData = function(data){
1668
+ if(!data || !data.sys) {
1669
+ return;
1670
+ }
1671
+ melo.data = melo.data || {};
1672
+ var dict = data.sys.dict;
1673
+ var protos = data.sys.protos;
1674
+
1675
+ //Init compress dict
1676
+ if(dict){
1677
+ melo.data.dict = dict;
1678
+ melo.data.abbrs = {};
1679
+
1680
+ for(var route in dict){
1681
+ melo.data.abbrs[dict[route]] = route;
1682
+ }
1683
+ }
1684
+
1685
+ //Init protobuf protos
1686
+ if(protos){
1687
+ melo.data.protos = {
1688
+ server : protos.server || {},
1689
+ client : protos.client || {}
1690
+ };
1691
+ if(!!protobuf){
1692
+ protobuf.init({encoderProtos: protos.client, decoderProtos: protos.server});
1693
+ }
1694
+ }
1695
+ };
1696
+
1697
+ module.exports = melo;
1698
+ })();
1699
+
1700
+ });
1701
+ require.register("boot/index.js", function(exports, require, module){
1702
+ var Emitter = require('emitter');
1703
+ window.EventEmitter = Emitter;
1704
+
1705
+ var protocol = require('@bigtyphoon/melo-protocol');
1706
+ window.Protocol = protocol;
1707
+
1708
+ var protobuf = require('@bigtyphoon/melo-protobuf');
1709
+ window.protobuf = protobuf;
1710
+
1711
+ var melo = require('pinus-jsclient-websocket');
1712
+ window.melo = melo;
1713
+
1714
+ });
1715
+ require.alias("boot/index.js", "melo-client/deps/boot/index.js");
1716
+ require.alias("component-emitter/index.js", "boot/deps/emitter/index.js");
1717
+ require.alias("component-indexof/index.js", "component-emitter/deps/indexof/index.js");
1718
+
1719
+ require.alias("node-melo-melo-protocol/lib/protocol.js", "boot/deps/melo-protocol/lib/protocol.js");
1720
+ require.alias("node-melo-melo-protocol/lib/protocol.js", "boot/deps/melo-protocol/index.js");
1721
+ require.alias("node-melo-melo-protocol/lib/protocol.js", "node-melo-melo-protocol/index.js");
1722
+
1723
+ require.alias("melonode-melo-protobuf/lib/client/protobuf.js", "boot/deps/melo-protobuf/lib/client/protobuf.js");
1724
+ require.alias("melonode-melo-protobuf/lib/client/protobuf.js", "boot/deps/melo-protobuf/index.js");
1725
+ require.alias("melonode-melo-protobuf/lib/client/protobuf.js", "melonode-melo-protobuf/index.js");
1726
+
1727
+ require.alias("pinusnode-pinus-jsclient-websocket/lib/melo-client.js", "boot/deps/pinus-jsclient-websocket/lib/melo-client.js");
1728
+ require.alias("pinusnode-pinus-jsclient-websocket/lib/melo-client.js", "boot/deps/pinus-jsclient-websocket/index.js");
1729
+ require.alias("pinusnode-pinus-jsclient-websocket/lib/melo-client.js", "pinusnode-pinus-jsclient-websocket/index.js");
1730
+