owebjs 1.5.2-dev → 1.5.3-dev
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/uwebsocket/server.js +29 -29
- package/package.json +1 -1
|
@@ -84,51 +84,51 @@ async function server_default({ cert_file_name, key_file_name }) {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
close(cb) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
if (uServer._socket) {
|
|
88
|
+
uWS.us_listen_socket_close(uServer._socket);
|
|
89
|
+
uServer._socket = null;
|
|
90
|
+
}
|
|
91
|
+
if (cb) cb();
|
|
90
92
|
}
|
|
91
93
|
start(host, port, cb) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (cb) cb(socket);
|
|
94
|
+
const callbackFunction = /* @__PURE__ */ __name(function(token) {
|
|
95
|
+
uServer._socket = token;
|
|
96
|
+
if (cb) cb(token);
|
|
96
97
|
}, "callbackFunction");
|
|
97
|
-
if (host && port
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
callbackFunction
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
if (!cb && (!port || typeof port === "function")) {
|
|
105
|
-
cb = port;
|
|
106
|
-
port = host;
|
|
107
|
-
args = [
|
|
108
|
-
port,
|
|
109
|
-
callbackFunction
|
|
110
|
-
];
|
|
98
|
+
if (host && port) {
|
|
99
|
+
return uServer.listen(host, port, callbackFunction);
|
|
100
|
+
} else {
|
|
101
|
+
return uServer.listen(port || host, callbackFunction);
|
|
111
102
|
}
|
|
112
|
-
return uServer.listen(...args);
|
|
113
103
|
}
|
|
114
104
|
listen(host, port, cb) {
|
|
115
105
|
if (typeof host === "object") {
|
|
116
106
|
const listenOptions = host;
|
|
117
107
|
port = listenOptions.port;
|
|
118
108
|
cb = listenOptions.cb;
|
|
119
|
-
host = listenOptions.host;
|
|
120
|
-
return this.start(host, port, (
|
|
121
|
-
|
|
122
|
-
|
|
109
|
+
host = listenOptions.host || "0.0.0.0";
|
|
110
|
+
return this.start(host, port, (token) => {
|
|
111
|
+
if (token) {
|
|
112
|
+
uServer._socket = token;
|
|
113
|
+
if (cb) cb(null, `http://${host}:${port}`);
|
|
114
|
+
} else {
|
|
115
|
+
if (cb) cb(new Error(`Failed to listen on ${host}:${port}`));
|
|
116
|
+
}
|
|
123
117
|
});
|
|
124
118
|
} else {
|
|
125
119
|
if ((!port || typeof port === "function") && !cb) {
|
|
126
120
|
cb = port;
|
|
127
121
|
port = host;
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
return this.start(host, port, cb);
|
|
122
|
+
host = "0.0.0.0";
|
|
131
123
|
}
|
|
124
|
+
return this.start(host, port, (token) => {
|
|
125
|
+
if (token) {
|
|
126
|
+
uServer._socket = token;
|
|
127
|
+
if (cb) cb(null, `http://${host}:${port}`);
|
|
128
|
+
} else {
|
|
129
|
+
if (cb) cb(new Error(`Failed to listen on ${host}:${port}`));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
ws(pattern, behaviors, hooks = []) {
|