space.chensheng.wsmessenger.common.reliable.ReliableAssembler Maven / Gradle / Ivy
The newest version!
package space.chensheng.wsmessenger.common.reliable;
import space.chensheng.wsmessenger.common.component.MessengerContext;
import space.chensheng.wsmessenger.common.component.Shutdownable;
/**
* A class assembles all messenger reliable functions.
* @author sheng.chen
*/
public abstract class ReliableAssembler implements Reliable, Shutdownable {
private WaitingMessageProcessor waitingMessageProcessor;
private PendingMessageProcessor pendingMessageProcessor;
public ReliableAssembler(WaitingMessageProcessor waitingMessageProcessor, PendingMessageProcessor pendingMessageProcessor) {
this.waitingMessageProcessor = waitingMessageProcessor;
this.pendingMessageProcessor = pendingMessageProcessor;
}
@Override
public void processWaitingResponse(R respMsg) {
waitingMessageProcessor.processWaitingResponse(respMsg);
}
@Override
public void waitingResponse(T msg, String receiverId, WaitingCallback callback, long timeout) {
waitingMessageProcessor.submitWaiting(msg, receiverId, callback, timeout);
}
@Override
public void waitingResponse(T msg, String clientId, WaitingCallback callback) {
waitingMessageProcessor.submitWaiting(msg, clientId, callback);
}
@Override
public void addPendingMessage(String receiverId, T message) {
this.pendingMessageProcessor.addPendingMessage(receiverId, message);
}
@Override
public void deliverPendingMessages(String receiverId) {
this.pendingMessageProcessor.deliverPendingMessages(receiverId);
}
@Override
public void shutdown() {
this.waitingMessageProcessor.shutdown();
this.pendingMessageProcessor.shutdown();
}
@Override
public boolean isShutdown() {
return true;
}
}