Hi guys, i used HashMap to combine the parameters i passed to the my rtmp:
nc.connect(_root.serverUrl, _root.username, _root.password, _root.room,
"actor");
I tried this method so I can pass it to my client object(IClient) as userInfo.
Then in the appDisconnect function, I retreived the userInfo object via
getClient() and
when I traced it the output is:
{password=1234, room=DEV_ROOM, username=DEV_Model_116970413 0215,
actor=actor}
I guess the format above is in hashMap, but when I try to use the Collection
Iterator like for (Iterator it =userInfo.entrySet().iterator(), it says that
the method entrySet is not found in the object "userInfo". What could be wrong
with my code? How can I convert the object back to hasMap? and how can I
retreive the attributes and values in an Object.
Below is my Red5 Codes:
----------------------------------------------------------------------------------------------------------------------
package demo;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.IClient;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.api.stream.IStreamCapableConnection;
import org.red5.server.api.stream.support.SimpleBandwidthConfigure;
import org.red5.server.api.service.ServiceUtils;
import org.red5.server.api.so.ISharedObject;
import org.red5.server.api.so.ISharedObjectService;
import java.util.HashMap;
import java.util.Map;
public class Application extends ApplicationAdapter {
private IScope appScope;
private IServerStream serverStream;
@Override
public boolean appStart(IScope app) {
appScope = app;
System.out.println("appStart::::::::::"+app);
return true;
}
@Override
public boolean appConnect(IConnection conn, Object[] params) {
String username = params[0].toString();
IClient client = conn.getClient();
client.setAttribute("username", username);
client.setAttribute("password", params[1].toString());
client.setAttribute("room", params[2].toString());
client.setAttribute("actor", params[3].toString());
HashMap<String, String> userInfo = new HashMap<String, String>();
userInfo.put("username",username);
userInfo.put("password",params[1].toString());
userInfo.put("room",params[2].toString());
userInfo.put("actor",params[3].toString());
client.setAttribute("userInfo", userInfo);
super.appConnect(conn, params);
return true;
}
@Override
public boolean appJoin(IClient client,IScope scope)
{
return true;
}
@Override
public void appDisconnect(IConnection conn) {
IClient client = conn.getClient();
Object userInfo = client.getAttribute("userInfo");
System.out.println("userInfo>" + userInfo);
// for (Iterator it =userInfo.entrySet().iterator();
// it.hasNext(); ) {
// Map.Entry entry = (Map.Entry)it.next();
// Object key = entry.getKey();
// Object value = entry.getValue();
// System.out.println("key value: " + key );
// System.out.println("map value: " + value );
// }
super.appDisconnect(conn);
}
}
Send instant messages to your online friends http://uk.messenger.yahoo.com _______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org