Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
/************************************************************************
2
 *  Copyright 2010-2015 Brian McKelvey.
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15
 ***********************************************************************/
16
 
17
var util = require('util');
18
var EventEmitter = require('events').EventEmitter;
19
 
20
function WebSocketRouterRequest(webSocketRequest, resolvedProtocol) {
21
    // Superclass Constructor
22
    EventEmitter.call(this);
23
 
24
    this.webSocketRequest = webSocketRequest;
25
    if (resolvedProtocol === '____no_protocol____') {
26
        this.protocol = null;
27
    }
28
    else {
29
        this.protocol = resolvedProtocol;
30
    }
31
    this.origin = webSocketRequest.origin;
32
    this.resource = webSocketRequest.resource;
33
    this.resourceURL = webSocketRequest.resourceURL;
34
    this.httpRequest = webSocketRequest.httpRequest;
35
    this.remoteAddress = webSocketRequest.remoteAddress;
36
    this.webSocketVersion = webSocketRequest.webSocketVersion;
37
    this.requestedExtensions = webSocketRequest.requestedExtensions;
38
    this.cookies = webSocketRequest.cookies;
39
}
40
 
41
util.inherits(WebSocketRouterRequest, EventEmitter);
42
 
43
WebSocketRouterRequest.prototype.accept = function(origin, cookies) {
44
    var connection = this.webSocketRequest.accept(this.protocol, origin, cookies);
45
    this.emit('requestAccepted', connection);
46
    return connection;
47
};
48
 
49
WebSocketRouterRequest.prototype.reject = function(status, reason, extraHeaders) {
50
    this.webSocketRequest.reject(status, reason, extraHeaders);
51
    this.emit('requestRejected', this);
52
};
53
 
54
module.exports = WebSocketRouterRequest;