Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add properties and functions to client and server #1

Conversation

vasco-santos
Copy link

@vasco-santos vasco-santos changed the title Feat/add properties and functions to client and server Feat: add properties and functions to client and server Sep 23, 2019
@vasco-santos vasco-santos changed the title Feat: add properties and functions to client and server feat: add properties and functions to client and server Sep 23, 2019
@vasco-santos
Copy link
Author

Note: tests are failing same way as already failing in master branch

client.js Outdated
@@ -7,12 +7,14 @@ var wsurl = require('./ws-url')

module.exports = function (addr, opts) {
const location = typeof window === 'undefined' ? {} : window.location
opts = opts || {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this to a default param instead of checking here. module.exports = function (addr, opts = {}) {

client.js Outdated

const stream = duplex(socket, opts)
stream.remoteAddress = url
stream.socket = socket

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Can we map stream.destroy to socket.terminate? This would give users the forceful close option.

server.js Outdated
@@ -41,6 +41,9 @@ module.exports = !WebSocket.Server ? null : function (opts, onConnection) {
wsServer.on('connection', function (socket, req) {
var stream = ws(socket)
stream.remoteAddress = req.socket.remoteAddress
stream.remotePort = req.socket.remotePort
stream.close = () => emitter.close()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't emitter.close() be socket.close()? emitter.close is going to shut the whole server down, not close the connection.

I'd also map stream.destroy to socket.terminate for consistency with the returned client streams.

@vasco-santos vasco-santos force-pushed the feat/add-properties-and-functions-to-client-and-server branch 2 times, most recently from d68d064 to dcb13a6 Compare September 26, 2019 11:14
@vasco-santos vasco-santos force-pushed the feat/add-properties-and-functions-to-client-and-server branch from dcb13a6 to c78168d Compare September 26, 2019 11:38
@alanshaw alanshaw merged commit 969ed7d into alanshaw:master Feb 7, 2020
@vasco-santos vasco-santos deleted the feat/add-properties-and-functions-to-client-and-server branch February 7, 2020 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants