We have a large application developed with JavaEE (primefaces, wildfly, Websocket). The idea behind the important functionality of our application is that if two or more users are online at same time then they can see each others status.
e.g. If 'Maik' and 'Andre' are online then Maik can see Andre's online status and Andre sees Maik's status.
We uses Websocket(Server endpoint, Javascript Websocket API at client sides).
Clients send their user-ids (UUID) over secure websocket to server, server saves them in a Hashmap(key: page-id where users are currently logged, value: user-id). Server returns a json string to clients and clients then send the string to backing bean with a parameterized RemoteCommand.
ws.onmessage = function(e) {
console.log("received msg: " + e.data);
showOnlineUsers([ {
name : 'jsonString',
value : e.data
} ]);
}
RemoteCommand in xhtml page is used as:
<p:remoteCommand name="showOnlineUsers"
action="#{bean.showOnlineUsers()}"
process="@form" update="OnlineUsersFormId:onlineUserId" />
The RemoteCommand calls a backing bean function - showOnlineUSers().
String jsonString = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("jsonString");
// Logic to extract jsonSting and generate a List of users.
// Set the users list for XHTML component.
setUsersList(list);
After calling the backing bean function, RemoteCommand updates a component "OnlineUsersFormId:onlineUserId" in XHTML page. The exact jsf component in the page is as below:-
<h:form id="OnlineUsersFormId">
<h:panelGroup id="onlineUserId">
<ui:repeat var="user" value="#{bean.getUsersList()}">
#{user.getUserName()}
</ui:repeat>
</h:panelGroup>
</h:form>
Problem: Logic works fine, but after working some time it suddenly stops workig when a user(Maik) leaves the page but his name is not being removed from other user's (Andre) page (Although the Server tells him to remove Maik's name- it also works fine only for some time). Our gut feeling says that something with "updating the component" in remoteCommand works abnormal.
Any help would be appreciated.
Best regards, Tahir