Experimental Stream Chat Implementation#483
Conversation
|
The React-side implementation is pretty simple. Most of the logic for handling the SSE stream and message state is contained in this commit: sleroq/web.cum.army@2c719a2. Beyond the chat, I've a added other quality-of-life improvements to the frontend on my fork. If you have a few minutes, I'd love for you to take a look! If someone likes it - I'd be more than happy to split them into PRs and contribute them back to the main repository. |
|
This is amazing! Thank you @sleroq I think we should merge this. Broadcast Box started as a 'Get WHIP merged into OBS project', but now that it is generally useful I want to get stuff like this merged! I am traveling today. Then I will work on getting this in :) |
|
@Sean-Der I'm going to contribute frontend side in a separate PR today/tomorrow. Current limitations:
Some questions:
|
|
I am so sorry about all the churn @sleroq. I really wanted to get a fork of Broadcast Box merged in, turned out to be more work then I anticipated :) Would you be interested in being added as a admin to this repo? I understand if you are hesitant, but this is what I see.
So if you are up for it I would love to work together with you. I would add you as admin and would love to hear where you think the project should go. I think it has so much potential, but I am not going to be able to achieve it on my own :( |
|
Thanks for the kind words, appreciate it. Yes, I'm down to be added as admin. Happy to help push things forward and share where I think the project could go. |
|
Done! You are an admin @sleroq The SSE isn't something we should modify (if possible) the SSE events come from https://www.ietf.org/archive/id/draft-ietf-wish-whep-03.html Would it be possible to Send/Receive messages via DataChannel instead? We should move the status/count to that as well. The goal should be that any standard WHIP/WHEP client works with Broadcast Box (FFmpeg/GStreamer) If you are up for it we should also move the stream status and other stuff off of SSE. I just haven't had time yet :( |
|
@sleroq do you want to rebase and land or I can! I have time tonight |
Sounds good. Will ping you when I have something to review. |
|
Hey @sleroq! I have the day off today. I can do the rebase, I can take it on! Unless you have started already. |
|
Already started working on this, need to test a bit more and I will push it in a few hours. @Sean-Der upd: small delay, need to make sure it's right |
|
Hell yea, amazing @sleroq After this lets do a 'big release' with profile + chat and this is the time to get people off non-free solutions :) |
|
Updated branch to use DataChannel and refactored a bit. The current implementation isn't perfect and I'd like to improve it further, but I stopped myself from adding too much so it's easier to review. I plan to add more features separately. Planned improvements in separate PRs:
Currently when a client connects, we send the entire chat history to them. It's fine overall, but with large chats it'll be too much data. I'll implement proper backfill to avoid sending everything to the client.
On my fork I already got irritated by losing history on each release, so I'll add a Redis storage option (default stays the same so it's easy to set up and Redis is not required). This is the reason for the storage abstraction. What do you think? |
|
I have frontend implementation almost ready, you can test it here - https://github.com/sleroq/broadcast-box/tree/chat-web Can't open chain of PR's here because it's external branch. |
|
Hell yea, will merge this tonight! Great job @sleroq If you have any other improvements/ideas would love to get those merged also. |
|
Thanks for making the PR manageable! Was very easy to read :)
SGTM!
Great plan! Maybe we can tie into webhooks somehow? I want to make the code as easy as possible to deploy. |
|
Nice work! Merged, I want to explore some changes but those can all be done after landing.
I also want to explore do we need dedicated state just for Chat? Could ChatManager operate directly on WHIP/WHEP Sessions? If we added an interface If you are up for exploring/make these changes I would love that! If not tell me and I can take them on tomorrow |
|
Also I want to explore making this as general as possible. Some users will want just generic pub/sub for messages. I think how you have chat today is REALLY close to that, but you want
Luckily we have the DataChannel label (thanks for doing that!) how much logic can we move into the clients? That lets/encourages people to do custom clients and Broadcast Box server can be used for as much custom stuff as possible. |
|
Hey @sleroq I am going to work on ^ and when done will merge the UI code you have been working on. Thank you so much for everything you have done :) |
|
@Sean-Der Sorry if I move too slow, trying to find time for all of the projects. Will make PR with UI today, and I have more UI improvements planned this week. Hopefully will get this done before the release. Thank you for guidance and kind words! |
I understand this, we need to keep minimal client implementation simple, tracking history and backfilling should not be necessary. I plan to make example OBS plugin for the chat. Will make sure you can just connect and pull new messages without handling any backfilling. |
|
@sleroq amazing! You aren’t slow at all. I’m used to people getting PRs in and then disappearing. I don’t take it personally at all. |
|
@sleroq I I am totally fine with history + backfilling being in the code base. If you put it in the backend means you don't need to put it in every client. After you merge the frontend I will work on some minor modification of backend code (that doesn't break the frontend in any way) no rush! |
Hi! Thank you for creating broadcast-box, it's really nice.
I played around a bit and implemented a chat feature my friends wanted. It's currently working only with my client at https://web.cum.army. Video demo. You can check out its source code at https://github.com/sleroq/web.cum.army.
I don't expect you to merge this, as it's more code to support. I just want to share this with you. But if you like it, I am happy to apply any suggestions and update the frontend as well.
Outdated overview
Technical Overview (generated by gemini)
The implementation follows the existing patterns of the project (plain Go net/http and SSE) to keep dependencies minimal:
API Surface
Thanks again for the great project!