MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / constructor

Method constructor

tests/helpers/proxy-server.js:8–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7class ProxyServer {
8 constructor() {
9 this.called = false;
10 this.lastReq = null;
11 this.httpServer = http.createServer((req, res) => {
12 this.called = true;
13 this.lastReq = req;
14 res.writeHead(200, { 'Content-Type': 'text/plain' });
15 res.end('okay');
16 });
17 this.httpServer.listen(3001);
18
19 let wsServer = new WebSocketServer({
20 httpServer: this.httpServer,
21 autoAcceptConnections: true,
22 });
23
24 let websocketEvents = (this.websocketEvents = []);
25 wsServer.on('connect', (connection) => {
26 websocketEvents.push('connect');
27
28 connection.on('message', (message) => {
29 websocketEvents.push(`message: ${message.utf8Data}`);
30 connection.sendUTF(message.utf8Data);
31 });
32
33 connection.on('error', (error) => {
34 websocketEvents.push(`error: ${error}`);
35 });
36
37 connection.on('close', () => {
38 websocketEvents.push(`close`);
39 });
40 });
41 }
42}
43
44module.exports = ProxyServer;

Callers

nothing calls this directly

Calls 3

createServerMethod · 0.80
listenMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected