com.zipwhip.api.signals.sockets.netty.SignalConnectionBaseConnectionHandleBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zipwhip-api Show documentation
Show all versions of zipwhip-api Show documentation
Java client to support applications powered by the Zipwhip Cloud
The newest version!
package com.zipwhip.api.signals.sockets.netty;
import com.zipwhip.api.signals.Writable;
import com.zipwhip.api.signals.commands.SerializingCommand;
import com.zipwhip.api.signals.sockets.ConnectionHandle;
import com.zipwhip.api.signals.sockets.ConnectionHandleBase;
import com.zipwhip.concurrent.ObservableFuture;
import com.zipwhip.util.Asserts;
/**
* Created with IntelliJ IDEA.
* User: msmyers
* Date: 9/5/12
* Time: 3:37 PM
*
* This is for "connections" that sit inside SignalConnectionBase. It follows the naming pattern of [class][base] even
* though it's redundant. I'm still looking for a better name than "Connection" since we have so many connection
* objects floating around.
*/
public abstract class SignalConnectionBaseConnectionHandleBase extends ConnectionHandleBase implements Writable {
private SignalConnectionBase signalConnection;
public SignalConnectionBaseConnectionHandleBase(long id, SignalConnectionBase signalConnection) {
super(id);
this.signalConnection = signalConnection;
}
@Override
protected void proxyDisconnectFromRequestorToParent(final ObservableFuture disconnectFuture, final boolean causedByNetwork) {
signalConnection.executor.execute(new Runnable() {
@Override
public void run() {
// the disconnectFuture that it returns will be the exact same future we already have
Asserts.assertTrue(
getDisconnectFuture() == disconnectFuture &&
disconnectFuture == signalConnection.disconnect(SignalConnectionBaseConnectionHandleBase.this, causedByNetwork), "The disconnectFutures must match!");
}
});
}
@Override
public synchronized ObservableFuture reconnect() {
return signalConnection.reconnect(this);
}
@Override
public ObservableFuture write(Object object) {
return signalConnection.send((SerializingCommand) object);
}
@Override
protected void onDestroy() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy