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

Allow for custom messages #17

Merged
merged 2 commits into from Sep 6, 2015
Merged

Allow for custom messages #17

merged 2 commits into from Sep 6, 2015

Conversation

@kpdecker
Copy link
Contributor

kpdecker commented Sep 5, 2015

This allows for the client to send custom messages to the server using the client.message API and the server to respond using the onMessage plugin callback option.

These are akin to raw access to the channel and do not provide any higher-level hapi features such as auth, request-based logging, etc.

kpdecker added 2 commits Sep 5, 2015
This allows for the client to send custom messages to the server using the `client.message` API and the server to respond using the `onMessage` plugin callback option.

These are akin to raw access to the channel and do not provide any higher-level hapi features such as auth, request-based logging, etc.
Some sort of state mechanism needed to be passed to this method, otherwise its usefulness is limited.
@kpdecker kpdecker force-pushed the custom-messages branch from dcf067e to 02bdd44 Sep 5, 2015
@kpdecker

This comment has been minimized.

Copy link
Contributor Author

kpdecker commented Sep 5, 2015

I'm not sure I like how the socket is being passed around here, but I was not sure of a better way to pass around some sort of state here. Pushing to the PR and I assume we can iterate.

@hueniverse hueniverse added the feature label Sep 6, 2015
@hueniverse hueniverse self-assigned this Sep 6, 2015
@@ -28,6 +28,7 @@ var internals = {

internals.schema = Joi.object({
onConnect: Joi.func(), // function (ws) {}
onMessage: Joi.func(), // function (message, reply) { reply(data); }
onUnknownMessage: Joi.func(), // function (message, ws) { ws.send('string'); }

This comment has been minimized.

Copy link
@hueniverse

hueniverse Sep 6, 2015

Member

Can we now drop onUnknownMessage?

This comment has been minimized.

Copy link
@kpdecker

kpdecker Sep 6, 2015

Author Contributor

Probably. I wanted to leave that out of this PR though. I'm thinking that it probably should go away since it doesn't quite work on the client side.

@@ -69,7 +69,7 @@ internals.Listener.prototype._add = function (ws) {
socket.authenticate(function () {

if (self._settings.onConnect) {
self._settings.onConnect(ws);
self._settings.onConnect(socket);

This comment has been minimized.

Copy link
@hueniverse

hueniverse Sep 6, 2015

Member

The question is what does onConnect() need?

@hueniverse hueniverse added this to the 0.3.0 milestone Sep 6, 2015
hueniverse added a commit that referenced this pull request Sep 6, 2015
Allow for custom messages
@hueniverse hueniverse merged commit a6c4c6a into master Sep 6, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@hueniverse hueniverse deleted the custom-messages branch Sep 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.