@domain.js/main 0.4.6 → 0.4.8
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.
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +19 -1
- package/package.json +1 -1
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const socket_1 = require("./socket");
|
|
|
27
27
|
const utils_1 = require("./utils");
|
|
28
28
|
function Main(cnf, deps) {
|
|
29
29
|
const utils = (0, utils_1.Utils)(cnf);
|
|
30
|
-
const { routers, domain, httpCodes, makeProfileHook } = deps;
|
|
30
|
+
const { routers, domain, httpCodes, makeProfileHook, socketLogger } = deps;
|
|
31
31
|
const server = restify.createServer();
|
|
32
32
|
server.use(restify.plugins.queryParser());
|
|
33
33
|
server.use(restify.plugins.bodyParser({
|
|
@@ -46,6 +46,24 @@ function Main(cnf, deps) {
|
|
|
46
46
|
// 根据需求起送socket服务
|
|
47
47
|
if (cnf.socket) {
|
|
48
48
|
const io = new socket_io_1.Server(server);
|
|
49
|
+
// 处理日志
|
|
50
|
+
if (socketLogger) {
|
|
51
|
+
io.on("connection", (socket) => {
|
|
52
|
+
const { emit } = socket;
|
|
53
|
+
socket.emit = (...args) => {
|
|
54
|
+
socketLogger("emit", socket.id, args);
|
|
55
|
+
return emit.apply(socket, args);
|
|
56
|
+
};
|
|
57
|
+
socketLogger("connection", socket.id, socket.handshake);
|
|
58
|
+
socket.use((args, next) => {
|
|
59
|
+
next();
|
|
60
|
+
socketLogger("use", socket.id, args);
|
|
61
|
+
});
|
|
62
|
+
socket.on("disconnect", (reason) => {
|
|
63
|
+
socketLogger("disconnect", socket.id, reason);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
49
67
|
(0, socket_1.BridgeSocket)(io, domain);
|
|
50
68
|
}
|
|
51
69
|
// Http server start
|