Skip to content

Make it possible to broadcast messages (data) to other websocket clients#354

Merged
Palakis merged 7 commits into
obsproject:4.x-currentfrom
julijane:4.x-current
Jul 26, 2019
Merged

Make it possible to broadcast messages (data) to other websocket clients#354
Palakis merged 7 commits into
obsproject:4.x-currentfrom
julijane:4.x-current

Conversation

@julijane
Copy link
Copy Markdown

@julijane julijane commented Jul 21, 2019

This PR adds a new function "BroadcastWebSocketMessage" which takes two parameters: realm and data. realm is intended to be a user-defined string to distinguish the source/recipient/scope of the message and data is the actual message.

Why?

With this change for example a javascript code in a browser source can connect to the websocket server and can receive such Messages and act upon them. This makes it possible for example to write some remote controlling software which triggers actions in a browser source without the need for any additional server.

Copy link
Copy Markdown
Contributor

@Palakis Palakis left a comment

Choose a reason for hiding this comment

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

Thanks for this! Here is some feedback regarding these changes:

Comment thread src/WSRequestHandler_General.cpp Outdated
Comment thread src/WSRequestHandler_General.cpp Outdated
Comment thread src/WSRequestHandler_General.cpp Outdated
Comment thread src/WSRequestHandler_General.cpp Outdated
@julijane
Copy link
Copy Markdown
Author

@Palakis Thank you for your review. I made the requested changes.

@julijane
Copy link
Copy Markdown
Author

@Palakis I was thinking about this. I think it would be neat if the broadcast would contain a identifier (e.g. the string from getRemoteEndpoint) for the source and the possibility to then send a response to just this source (so another request SendWebSocketMessage which gets realm, data and target). However to do this the source string (or the connection_hdl) would need to be available in the RequestHandler. This should be doable but what are your feelings about this idea?

Copy link
Copy Markdown
Contributor

@Palakis Palakis left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! Everything is good, just a few things I didn't catch before regarding documentation and naming.

Comment thread src/WSRequestHandler_General.cpp Outdated
Comment thread src/WSRequestHandler_General.cpp Outdated
Copy link
Copy Markdown
Contributor

@Palakis Palakis left a comment

Choose a reason for hiding this comment

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

Almost good! Gonna run a last batch of tests after that.

Comment thread src/WSEvents.cpp Outdated
@Palakis Palakis merged commit add3075 into obsproject:4.x-current Jul 26, 2019
@julijane
Copy link
Copy Markdown
Author

@Palakis Something went wrong with the automatic protocol.md generation. The entry in event section is missing the return values and the entry in the command section is missing alltogether.

@Palakis
Copy link
Copy Markdown
Contributor

Palakis commented Jul 26, 2019

@julijane Both the command spec used @param (specific to typedefs) instead of @return, and the command spec had its @api field set to general instead of requests. Just fixed it.

@julijane
Copy link
Copy Markdown
Author

@Palakis Oops i'm sorry for that mistake. Thanks for fixing already!

@julijane
Copy link
Copy Markdown
Author

@Palakis You made a mistake though, see PR

@Palakis Palakis added this to the 4.7 milestone Nov 12, 2019
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