8 examples of 'wss listen' in JavaScript

Every line of 'wss listen' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
43(listener: Listener): void
44{
45 this.listener_ = listener;
46 this.connection_.on("message", this._Handle_message.bind(this));
47}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

160listen(server) {
161 this._wsServer = new ws.Server({ server });
162 this._wsServer.on('connection', this._onConnection.bind(this));
163}
57server.listen(function onListen () {
58 var addr = server.address()
59 var session = http2.connect('http://localhost:' + addr.port)
60 var request = session.request({ ':method': 'POST', ':path': '/' })
61
62 request.end('hello, world!')
63
64 request.on('response', function onResponse (res) {
65 getRawBody(request, { encoding: true }, function (err, str) {
66 http2close(server, session, function onClose () {
67 assert.ifError(err)
68 assert.strictEqual(str, 'stream encoding should not be set')
69 done()
70 })
71 })
72 })
73})
35listen(port: number) {
36 this._server.listen(port)
37 debug('listen')
38}
141function listen(conn) {
142 if (conn.db._listening) {
143 return;
144 }
145 conn.db._listening = true;
146
147 conn.db.on('close', function() {
148 if (conn._closeCalled) return;
149
150 // the driver never emits an `open` event. auto_reconnect still
151 // emits a `close` event but since we never get another
152 // `open` we can't emit close
153 if (conn.db.serverConfig.autoReconnect) {
154 conn.readyState = STATES.disconnected;
155 conn.emit('close');
156 return;
157 }
158 conn.onClose();
159 });
160 conn.db.on('error', function(err) {
161 conn.emit('error', err);
162 });
163 conn.db.on('reconnect', function() {
164 conn.readyState = STATES.connected;
165 conn.emit('reconnected');
166 conn.onOpen();
167 });
168 conn.db.on('timeout', function(err) {
169 conn.emit('timeout', err);
170 });
171 conn.db.on('open', function(err, db) {
172 if (STATES.disconnected === conn.readyState && db && db.databaseName) {
173 conn.readyState = STATES.connected;
174 conn.emit('reconnected');
175 }
176 });
177 conn.db.on('parseError', function(err) {
178 conn.emit('parseError', err);
179 });
180}
60function listen (conn) {
61 if (conn._listening) return;
62 conn._listening = true;
63
64 conn.db.on('close', function(){
65 if (conn._closeCalled) return;
66
67 // the driver never emits an `open` event. auto_reconnect still
68 // emits a `close` event but since we never get another
69 // `open` we can't emit close
70 if (conn.db.serverConfig.autoReconnect) {
71 conn.readyState = STATES.disconnected;
72 conn.emit('close');
73 return;
74 }
75 conn.onClose();
76 });
77 conn.db.on('error', function(err){
78 conn.emit('error', err);
79 });
80 conn.db.on('timeout', function(err){
81 var error = new Error(err && err.err || 'connection timeout');
82 conn.emit('error', error);
83 });
84 conn.db.on('open', function (err, db) {
85 if (STATES.disconnected === conn.readyState && db && db.databaseName) {
86 conn.readyState = STATES.connected;
87 conn.emit('reconnected')
88 }
89 })
90}
81function listen(options) {
82 var self = this
83 , opts = options || {}
84 , iface = options.url
85
86 if (!iface) {
87 iface = url.format(opts)
88 }
89
90 debug('Listening to %s.', iface)
91
92 self._initSocket()
93 self._zdealer.bind(iface)
94
95 return self
96}
31listen(server, callback) {
32 server.listener = net.createServer(server.handleRequest.bind(server));
33 server.listener.listen(server.options.port, callback);
34 server.listener.on('error', server.handleError.bind(server));
35}

Related snippets