IScope scope = (WebScope) conn.getScope();
IContext context = (Context) scope.getContext();
IClientRegistry reg = context.getClientRegistry();
IServiceCapableConnection serviceCapCon = null;
//start standard process
assertTrue(conn.connect(scope));
//go through the client list and send at least one message to everyone
for (String worker : workerList) {
//dont send to ourself
if (name.equals(worker)) {
log.debug("Dont send to self");
continue;
}
if (reg.hasClient(worker)) {
IClient recip = reg.lookupClient(worker);
Set<IConnection> rcons = recip.getConnections(scope);
//log.debug("Recipient has {} connections", rcons.size());
Object[] sendobj = new Object[] { client.getId(), "This is a message from " + name };
for (IConnection rcon : rcons) {
if (rcon instanceof IServiceCapableConnection) {
serviceCapCon = (IServiceCapableConnection) rcon;
serviceCapCon.invoke("privMessage", sendobj);
break;
} else {
log.info("Connection is not service capable");
}
}
} else {
log.warn("Client not registered {}", worker);
}
}
//number of connections
int connectionCount = workerList.size();
//now send N messages to random recipients
for (int i = 0; i < 4000; i++) {
String worker = workerList.get(rnd.nextInt(connectionCount));
//dont send to ourself
if (name.equals(worker)) {
//log.debug("Dont send to self");
continue;
}
if (reg.hasClient(worker)) {
IClient recip = reg.lookupClient(worker);
Set<IConnection> rcons = recip.getConnections(scope);
//log.debug("Recipient has {} connections", rcons.size());
Object[] sendobj = new Object[] { client.getId(), "This is a message from " + name };
for (IConnection rcon : rcons) {
if (rcon instanceof IServiceCapableConnection) {
serviceCapCon = (IServiceCapableConnection) rcon;
serviceCapCon.invoke("privMessage", sendobj);
break;
} else {
log.info("Connection is not service capable");
}
}