I have a problem with the way sessions and conversations are handled in Seam. We have some rather long forms where most of the time you start filling in the first screen and then some actions are executed in the background and the users leave the computer to do some work, and then later they come back and annotate the work.
Problem is that most of the time the sessions time out or the conversations timed out. While the second one can be easily fixed by splitting the workflow, the first is more important, since the user has to log back in, navigate to the right screen and only then can enter the annotation.
Is there a simple way to have a snippet of Ajax that would trigger a refresh of the session in the background. This would allow us to keep the sessions alive indefinitely.
Also is there an easy way to keep conversations alive?
Are you using RichFaces? We use something like this to keep the session alive.
<a4j:poll interval="10000" reRender="form1" action="#{logger.userIsAlive}" />
The "action" attribute is optional, we use it to keep a record of the connected users. We don't use conversations but I would say that this would also keep the conversation alive.
If you are not using RichFaces, then you could use an AJAX framework like JQuery to ping the server by calling a Servlet for example.
Related
I’m having some trouble understanding how to inplement presence channels in a real-time laravel application.
From what i’ve read in the documentation and a lot of other online resources about this, i only need to broadcast on a Presence channel and have clients listen on that particular channel. By the way, I'm using laravel 5.6 and on the front end I use Larvel Echo.
So, my problem is that channel name I need to broadcast to. If it’s something generic like “chat”, ALL the users in my application will broadcast to this channel and users who have no ideea who that user is (not a friend) receive this notification and they have to process this new information. Ofcourse I can choose not to update the UI or just do nothing if the user is not in their friends list but this just seems like a lot of useless procesaing of notifications on the client side. Doesn’t seem like a good ideea in my opinion.
Second option would be to broadcast presence to a unique channel name like “chat-[unique]” where “[unique]” would be something like the logged user’s id/hash but this just means that every client that loggs in the application has to listen for ALL friends notifications, so he has to connect to chat-5426, chat-9482, chat-4847 and so on, for all his friends. Again, this does not seem efficient. But that’s not all. The friends list is paginated so a user, after is logged in, only sees his first 20 friends (unless he scrolls down) and I have no limit on how many friend a user can have - I can implement a limit but still, it would be in the thousands so I don’t think I can get all the users from the DB in one query. I had the ideea of using this last method, to listen to each user's channel on the front end just as they are, paginated. Then, when scrolling and navigation arround, if a new user is visible in the viewport, add it to my friends object (no UI change) and start listening on his presence channel. I can see this method failing pretty easy though.
However I think about this, it always seems like online presence is verry resource consuming and almost not worth it for a small startup, I don't know. I have no ideea what a good way would be to implement it as I`ve never done it before. I would greatly appreciate any help with this because all online resources I've found on the subject implement the first method I asked about, all users connectiong to a generic channel but this always works in tutorials because they only have like 2-3 users in the DB and none mantion a user having friends. I can't see this working in the real world, but I may be wrong.
Thanks in advance
I have two users who joins a MediaMode::ROUTED Session. Both users PUBLISHES their cameras and microphones and SUBSCRIBES to the corresponding PUBLISHED video feed. I'm building a web app that can be used for communication using your Opentok.js.
My current JavaScript codes follows the idea of the AutomaticReconnection (discussed on this URL: https://tokbox.com/developer/guides/connect-session/js/#automatic_reconnection).
Note that the users who are testing my codes are in different countries (e.g. in Amsterdam - Netherlands and in the Philippines). Neither of the users triggers the 'disconnect()' method of the Session - we have a "STOP" button that triggers the 'disconnect()' Session method. And with several tests that we did, the test users' Session always gets the 'clientDisconnected' event. I have used Tokbox Session Inspector and it has been consistent that I see 'clientDisconnected' as the cause of our Session disconnection.
Based on the documentation:
"clientDisconnected" — A client disconnected from the session by calling the disconnect() method of the Session object or by closing the browser. ( See Session.disconnect().)
Why do our test users always get 'clientDisconnected' with my MediaMode::ROUTED session?
What could be the possible cause of this?
Regards,
It's hard to explain this behaviour without more information such as the code you use to connect/publish/subscribe.
It may be easier if you create a TokBox support ticket at https://support.tokbox.com/hc/en-us/requests/new and include the relevant session ID and connection IDs so the server side logs can be examined.
I'm working on a real-time chat. I need to change statuses of the room owner and connected users, together with the UI. Since NodeJS/SocketJS/etc don't guarantee message delivery, I switched to pure Ajax for that.
The system works like that:
- User presses a button to change his status
- An Ajax request is being sent to the server, and a status change request is being saved in the queue in DB
- Users send Ajax heartbeats every second. On the server this heartbeat function also processes the queue (when sent by the room owner). Besides it sends the current statuses of users in the room in response every time.
The issue is: there might be temporary internet problems on both sides, which causes all kinds of problems. This happens due to the fact, that the heartbeat Ajax requests are being processed in an arbitrary order on the server, or the responses are being received in a wrong order on the client side. As a result users have wrong data about current statuses and the UI changes are also wrong.
What is the best approach when making a system like that? What am I doing wrong or how can I fix the issues above?
Thank you!
Have a look at Max's blog a Django-Realtime-Chat and how he does it.
I want to make an online DB based chat application. My problem is to detect changes in the DB, i.e. whenever a user sends a message to another user it should display to him. One approach is Ajax calls with setinterval but I want an instant solution. I do not want to keep the server busy with such Ajax calls.
I'm wondering how it's implemented in Gmail, that every time you receive e-mail, the list of mails is automatically refreshed. It looks like the server is sending some kind of event to the browser, but how is it possible? Or maybe it’s simle: the browser ask the server for new messages every let’s say 2 seconds? But it would probably kill the performance…
Anyone have some ideas?
EDIT: OK, so if it's the simple answer, how do they manage performance? When I send an email from an other account to the gmail account the view is "refreshed" almost instantly. You were saying about a simple function that returns true / false, but it must have some logic (db connection or reads some files). How they manage it?
See also: How is GMail Chat able to make AJAX requests without client interaction?
Dont know exactly which technoloy Gmail uses, but the concept is to open a channel - using reverse AJAX, comet or sprocket based techniques.
Think of it as the client requesting the server for data, but the server does not return for one minute unless it has new mail. Using this technique, the client can almost show the results in a real time manner and it does not have to poll every 2 secs. Makes sense?
gmail is, in fact, polling the server for updates. Not as often as every two seconds, though. That would be madness. A bit of testing with Tamper Data makes it look like maybe every 20 seconds, though there seem to be multiple events going through that confuse it a bit.
Regarding your edit, I imagine they might have a last-activity timestamp on the account tracking in their database, with the client polling query retrieving that via Ajax and comparing with its last sync to determine whether it needs to do a full update.
You have right with simple answer. Google Mail checking new messages on server via AJAX.
It must be some kind of ajax listener that get informations every X seconds.
I already set something like that for one of my projects. What I was doing is calling a function that was returning true or false. True if the page needed to be refreshed, false otherwise. Then if you have an update, you do another call to get the actual update. This way you don't have to refresh everything every time... but it's still intense on the server if you have a lot of users.
In other words and like chaos said, it's polling the server.