I have tried in all the way, but couldn't get the solution yet. Still the same session getting close when the page gets the refresh. The Same session also getting close. Please, could you help with some code?
I have tried in all the way, but couldn't get the solution yet. Still the same session getting close when the page gets the refresh. The Same session also getting close. Please, could you help with some code?
Sorry but now I'm no longer sure I understood your goals correctly.
If a page is handling a session S1 and gets the refresh, then the new page tries to open a second session S2.
In this scenario, you can only manage to close S1 and let S2 succeed.
Are you trying to achieve somenthing different?
If you agree that S1 is the one that should be closed, then our suggestion is to keep two maps, in addition to the sessions map that you may need for your own purposes:
Then I see that your code examples involve further processing, like uniquelyIdentifyClient (which now I realize that you borrowed from our chat demo).Code:private ConcurrentHashMap<String,Map<String,String>> sessions = new ConcurrentHashMap<String,Map<String,String>>(); private ConcurrentHashMap<String,String> userInfo = new ConcurrentHashMap<String,String>(); private ConcurrentHashMap<String,String> sessionUser = new ConcurrentHashMap<String,String>(); public void notifyNewSession(String user, String session, Map sessionInfo) throws CreditsException, NotificationException { assert(! sessions.containsKey(session)); assert(! sessionUser.containsKey(session)); if (userInfo.containsKey(user)) { throw new ConflictingSessionException(-8, "Previous session termination", null, userInfo.get(user)); } else { sessions.put(session, sessionInfo); userInfo.put(user, session); sessionUser.put(session, user); } } public void notifySessionClose(String session) throws NotificationException { assert(sessions.containsKey(session)); assert(sessionUser.containsKey(session)); sessions.remove(session); String relatedUser = sessionUser.remove(session); userInfo.remove(relatedUser); }
Note that I dodn't include them, as I don't know your requirements on those aspects.
Thanks for your reply.
This is working for me now. When I refresh the page it didn't get terminate the currently active session. But my goal is I have to terminate if any other session opened with my credential.(User Name is unique.) If anyone opened my application by using my credential in that time If I open my browser means my session only should be active and their session should get inactive and force their page to logout. Now I think It getting terminate the existing session.(I have checked in 2 browsers by using the same credential ). But I didn't get any response from Ls while getting terminate the session. If I get the session lost message means I could force the logout the page from the client side. Is it possible getting response while terminate the session.
I have tried in this way
lsClient.addListener({
onServerError: function(errorCode, errorMessage) {
//here you can consume the error
console.log("Connection Error: " + errorCode, errorMessage);
}
});
onSubscriptionError: function(errorCode, errorMessage) {
//here you can consume the error
console.log(errorMessage);
},
onCommandSecondLevelSubscriptionError:function(err orCode,errorMessage,relatedkey) {
//this one can only be fired in case a two-level subscription is created
//here you can consume the error
}
Last edited by rvkvino; November 6th, 2017 at 12:48 PM.
If you refresh the page, the old page should be destroyed before it can get the session close notification;
but if you open a new page on a different browser, the previous page is supposed to receive an invocation in onServerError, notifying error code 35.
It is strange that you didn't see anything.
We have to trace what happens.
Please reproduce the case on a dedicated Server instance, by opening only the two involved pages on two different browsers.
To keep the logs short, you should also prevent the pages from performing subscriptions, which are not relevant in this case.
As a first step, show us the Server log, taken after setting LightstreamerLogger.push at DEBUG level.
Bookmarks