}
if (connection != null) {
// remove the protocol from the receiver url
String protocol = "xmpp:";
if (!receiver.startsWith(protocol)) {
throw new JSONRPCException("Receiver url must start with '"
+ protocol + "' (receiver='" + receiver + "')");
}
// username@domain
String fullUsername = receiver.substring(protocol.length());
connection.send(fullUsername, request, callback);
} else {
// TODO: use an anonymous xmpp connection when the sender agent has
// no xmpp connection.
throw new JSONRPCException("Cannot send an xmpp request, "
+ "agent has no xmpp connection.");
}
}