I would like to know how I could map the users that connect based on their unique id's and id session so that when there are more than 3 sessions for that id, the users who connected first are removed from the hashmap and so on.
Example:
UserID:3 Session:1980002
UserID:3 Session:2841111
UserID:3 Session:84848
The UserID already contains 3 active sessions, the oldest one is removed and the KillSession invoked, giving way to new.
UserID:3 Session:2841111
UserID:3 Session:84848
UserID:3 Session:4848880
Code:
public void onHTTPCupertinoStreamingSessionCreate(HTTPStreamerSessionCupertino httpSession) {
String User_Session = httpSession.getSessionId();
String Client_ID = httpSession.getProperties().getPropertyStr("sql_client_id");
/* Verifies that there are already 3 active sessions and removes the oldest,
since the limit of simultaneous sessions is 3 for each user,
and add to hashmap, Client_ID and User_Session */
}
public void onHTTPCupertinoStreamingSessionDestroy(IHTTPStreamerSession httpSession) {
String User_Session = httpSession.getSessionId();
//remove from hashmap, Client_ID based on session User_Session
}
public void KillSession(int SessionId){
IApplicationInstance Instance = applicationInstance;
IHTTPStreamerSession sessions = Instance.getHTTPStreamerSessions().get(SessionId);
sessions.rejectSession();
//remove from hashmap, Client_ID based on session User_Session
}
The Client_ID is the id of the user in the database, the User_Session is the unique session in the wowza generated for each connection, this session does not have equal values, that is, if the same Client_ID connects more than once, that value will be different For each of your sessions.
That is, basically my difficulty is to mount the hashmap, how could I do this?
If you want to add and remove in insertion order, use a LinkedHashMap. (A simple version of what might be of help)