switch (state)
{
case OPEN:
state = CLOSING;
connectionClose(replyCode, replyText, _options);
Waiter w = new Waiter(lock, timeout);
while (w.hasTime() && state == CLOSING && error == null)
{
w.await();
}
if (error != null)
{
close(replyCode, replyText, _options);
throw new ConnectionException(error);
}
switch (state)
{
case CLOSING:
close(replyCode, replyText, _options);
throw new ConnectionException("close() timed out");
case CLOSED:
break;
default:
throw new IllegalStateException(String.valueOf(state));
}
break;
case CLOSED:
break;
default:
if (sender != null)
{
sender.close();
w = new Waiter(lock, timeout);
while (w.hasTime() && sender != null && error == null)
{
w.await();
}
if (error != null)
{
throw new ConnectionException(error);