[Cppcms-users] Server Sent events and CppCMS
Brought to you by:
artyom-beilis
From: Barbu P. - G. <bar...@gm...> - 2012-08-09 10:22:20
|
Hello. I have the following app https://github.com/paullik/webchat/blob/master/src/index.py it is a webchat that uses AJAX and server sent events (SSE). But I'd like (for exercise) to port it to C++ using CppCMS. I have some issues though: 1. How can I implement in CppCMS a function that acts like my sse_stream python function? Namely: this function has to return a response when something happens (a user says something on the chat) and then it has to continue working, so it should be a blocking function that patiently waits for users to submit messages via AJAX and when a message arrives it should send it as a response, then wait for another message and so on. 2. There (in my python app) I use redis to publish a message to all subscribers, because the application creates a thread for each connection, any of these threads can publish something (any user can send a message) and via redis I collect them and send them to everyone using sse_stream. The issue is that I'm unsure about how to replicate this system. I'd like to use only the RAM, so I'd like to get rid of redis. Will it work if I create a vector of messages (or a queue) where I'll store the messages and I'll pass this vector to the function at point 1 to sent the messages to the other users, then remove that message from the vector in order to be prepared for the next one? Please let me know what you think, I'll provide more details or I'll try to provide a better explanation of what I'm trying to do. PS: As you can see I'm a C++ beginner, please be kind... -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik |