samedi 31 janvier 2015

Updating Red5 SharedObject closing stream


Vote count:

0




I'm trying to create a voice conference room with all users can speak and use the mic. But as an Admin, I should have the privilege to mute any user. So, I add to the user an attribute for the mic which will be check in client side and enable/disable user's mic accordingly. The server side code looks like:



String identifier;
String userID;
private int _gId = 1;
private Map<String,Object> newUser;
@Override
public boolean appConnect(IConnection conn, Object[] params) {

identifier = (String)params[1];
userID = (String)params[0];
int _globalUserId = _gId++;

conn.getClient().setAttribute("id", _globalUserId);

newUser = new HashMap<String,Object>();
newUser.put("identifier", (String)params[0]);
newUser.put("mic", 1); //mic value to be checked in client side
return true;
}

@Override
public boolean roomJoin(IClient client, IScope scope) {
ISharedObject so = getSharedObject(scope, "users_so");
so.setAttribute(userID,newUser);

return true;
}

@SuppressWarnings("unchecked")
public void muteUser(String userID){
IScope scope = Red5.getConnectionLocal().getScope();
ISharedObject so = getSharedObject(scope, "users_so");
Map<String,Object> user= new HashMap<String,Object>();
user = (Map<String, Object>) so.getAttribute(userID);
if(user != null){
user.put("mic", 0);
so.beginUpdate();
boolean removed = so.removeAttribute(userID);
boolean updated = so.setAttribute(userID,user);
so.endUpdate();
log.info("Mic: " + user.get("mic"));
log.info("Removed: " + removed);
log.info("Updated: " + updated);
}

}


The problem rises when I try to call the muteUser method. Red5 says that the stream is closed. I think this happens when I remove the attribute of the user and added it again but I couldn't find another way to update the sharedObject's mic value.


Does any one have a better idea to update a sharedObject without loosing stream??


Thank you



asked 41 secs ago







Updating Red5 SharedObject closing stream

Aucun commentaire:

Enregistrer un commentaire