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

Peer connect and event websocket connection hooks. #316

Merged
merged 2 commits into from
Jun 14, 2016

Conversation

AdamMagaluk
Copy link
Collaborator

@AdamMagaluk AdamMagaluk commented Jun 1, 2016

Implements #314

.use(function() {
  // Peer connection
  server.httpServer.onPeerConnect(function(request, socket, head, next) {
    // Handle auth logic, 
    next(); // Continue the peering process
    // or
    next(new Error('Some error')); // Response to peer will be 500
  })

  // Regular data websocket connections
  server.httpServer.onEventWebsocketConnect(function(request, socket, head, next) {
    // Handle auth logic, 
    next(); // Continue the event_socket process
    // or
    next(new Error('Some error')); // Response to client will be 500
  })
})

It also allows for multiple hooks for each event by calling the method more than once. In that case each hook is called in series.

@mdobson
Copy link
Contributor

mdobson commented Jun 6, 2016

+1

@AdamMagaluk AdamMagaluk merged commit 70334a8 into master Jun 14, 2016
@AdamMagaluk AdamMagaluk deleted the ws-upgrade-hooks branch June 14, 2016 13:04
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.

2 participants