> > > As I said, I've already gone over the websocket_messaging.py file - it > has dealings with WebSockets - NOT SSE (!) - and via Tornado, NOT web2py... >
We all got that. it's an external process, but it's implemented already, it "just works", has a simple yet powerful routing algo and its secure. With SSE you have to do it yourself. > >> I didn't get what you mean by "can I explicitely call it": either with >> websockets or SSE as soon as the user hits the page, a connection is >> established and remains open. There's no request/response cycle, just a >> request coming in and a (eventually) infinite response out. >> > > What I mean, is that once the connection is ope, and say, is handled by a > "session", then from that moment on, My usage of this connection would be > "pushing" through that connection onto the browser. The usage of the "push" > would obviously be from another controller. > I mean, let's take the "chat" use-case : > User "A" logs into a chat-view, and that sends a GET request to a > controller-action, who's job is to opens an SSE connection for that user - > a long-lasting session - let's call it "The SSE action". Then user "B" > logs into the same view on his side, and the same thing happens for him. Now > we have 2 outgoing sessions open - one for each user - 2 "SSE Actions" are > waiting to send more responses - each to their respective recipients. > Now, user "A" writes a comment, and "submits" it. This sends a POST > request to a different controller-action that saves the comment to the > database -let's call it "The Submission Action". This controller-action is > different from the SSE action, and may theoretically even belong to a > different controller (say, the system may have chat-views in multiple > pages...). > This is exactly the example shown on the videos about websocket_messaging.py . the user receives updates through the ws, and he sends to the default web2py installation with a simple ajax post its message. web2py then queues that message to tornado, that informs all connected users of the new message on the ws channel. > My question is, then : > "Can a submission-action 'call' an SSE-action that belongs to a different > controller, and has a different session/request/response object(s)? If so > How?". > On the SSE side, you'd have some controller that basically does: def events(): initialization_of_sse while True: yield send_a_message you have to think to security, routing, etc by yourself. Basically in that while True loop you'd likely want to inspect your "storage" (redis, ram, dict, database, whatever) if there's a new message for the user. You can't "exit" from there and resume it....all the logic needs to happen inside that yield(ing) loop. -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.