*/
private synchronized RegistrationResult connectSync() throws IOException {
boolean ok = false;
try {
if(connection == null) {
final ProtocolChannelClient client = ProtocolChannelClient.create(configuration);
CallbackHandler callbackHandler = null;
SSLContext sslContext = null;
if (realm != null) {
sslContext = realm.getSSLContext();
CallbackHandlerFactory handlerFactory = realm.getSecretCallbackHandlerFactory();
if (handlerFactory != null) {
String username = this.username != null ? this.username : localHostName;
callbackHandler = handlerFactory.getCallbackHandler(username);
}
}
// Connect
connection = client.connectSync(callbackHandler, Collections.<String, String> emptyMap(), sslContext);
connection.addCloseHandler(new CloseHandler<Connection>() {
@Override
public void handleClose(final Connection closed, final IOException exception) {
synchronized (this) {
if(connection == closed) {