protected Object execute(Object thiz, Object[] args) throws Exception {
// If no arguments, stop hosting on any hosted connection
if(args.length == 0) {
try {
ConnectionObject scriptHostedConn = (ConnectionObject) getHostedConn();
BBMPlatformConnection hostedConn = scriptHostedConn.getConnection();
hostedConn.setPrivate();
} catch(Exception e) {
// do nothing
}
// Otherwise, begin hosting on the connection provided
} else {
// If already hosting a public connection, stop it
Object hostedConnObj = getHostedConn();
if(! hostedConnObj.equals(UNDEFINED)) {
BBMPlatformConnection hostedConn = ((ConnectionObject) hostedConnObj).getConnection();
hostedConn.setPrivate();
}
final ConnectionObject connection = (ConnectionObject) args[0];
final ScriptableFunction onComplete = (ScriptableFunction) args[1];
_onJoinReqReceived = (ScriptableFunction) args[2];