Make handleRequest optional in WebSocketResources

If no request handler is provided, respond with 404 to any incoming
requests.
pull/749/head
lilia 10 years ago
parent cd363bd84d
commit 637cbcbf99

@ -38563,7 +38563,14 @@ TextSecureWebSocket = function (url, opts) {
);
};
window.WebSocketResource = function(socket, handleRequest, keepalive) {
window.WebSocketResource = function(socket, opts) {
opts = opts || {};
var handleRequest = opts.handleRequest;
if (typeof handleRequest !== 'function') {
handleRequest = function(request) {
request.respond(404);
};
}
this.sendRequest = function(options) {
return new OutgoingWebSocketRequest(options, socket);
};

@ -92,7 +92,14 @@
);
};
window.WebSocketResource = function(socket, handleRequest, keepalive) {
window.WebSocketResource = function(socket, opts) {
opts = opts || {};
var handleRequest = opts.handleRequest;
if (typeof handleRequest !== 'function') {
handleRequest = function(request) {
request.respond(404);
};
}
this.sendRequest = function(options) {
return new OutgoingWebSocketRequest(options, socket);
};

Loading…
Cancel
Save