use of com.tvd12.ezyfoxserver.client.constant.EzySocketStatus in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method processReceivedMessages.
protected void processReceivedMessages() {
EzySocketStatus status = socketStatuses.last();
if (status == EzySocketStatus.CONNECTED) {
if (socketReader.isActive()) {
processReceivedMessages0();
}
}
EzySocketStatus statusLast = socketStatuses.last();
if (isSocketDisconnectable(statusLast)) {
if (socketReader.isStopped()) {
onDisconnected(disconnectReason);
} else if (socketWriter.isStopped()) {
onDisconnected(disconnectReason);
}
}
}
use of com.tvd12.ezyfoxserver.client.constant.EzySocketStatus in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method reconnect.
public boolean reconnect() {
EzySocketStatus status = socketStatuses.last();
if (!isSocketReconnectable(status)) {
EzyLogger.warn("socket is not in a reconnectable status");
return false;
}
int maxReconnectCount = reconnectConfig.getMaxReconnectCount();
if (reconnectCount >= maxReconnectCount)
return false;
socketStatuses.push(EzySocketStatus.RECONNECTING);
int reconnectSleepTime = reconnectConfig.getReconnectPeriod();
connect0(reconnectSleepTime);
reconnectCount++;
EzyLogger.info("try reconnect to server: " + reconnectCount + ", wating time: " + reconnectSleepTime);
EzyEvent tryConnectEvent = new EzyTryConnectEvent(reconnectCount);
socketEventQueue.addEvent(tryConnectEvent);
return true;
}
use of com.tvd12.ezyfoxserver.client.constant.EzySocketStatus in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method processStatuses.
protected void processStatuses() {
socketStatuses.popAll(localSocketStatuses);
for (int i = 0; i < localSocketStatuses.size(); ++i) {
EzySocketStatus status = localSocketStatuses.get(i);
if (status == EzySocketStatus.CONNECTED) {
EzyEvent evt = new EzyConnectionSuccessEvent();
socketEventQueue.addEvent(evt);
} else if (status == EzySocketStatus.CONNECT_FAILED) {
EzyEvent evt = new EzyConnectionFailureEvent(connectionFailedReason);
socketEventQueue.addEvent(evt);
break;
} else if (status == EzySocketStatus.DISCONNECTED) {
EzyEvent evt = new EzyDisconnectionEvent(disconnectReason);
socketEventQueue.addEvent(evt);
break;
}
}
localSocketStatuses.clear();
}
use of com.tvd12.ezyfoxserver.client.constant.EzySocketStatus in project ezyfox-server-android-client by youngmonkeys.
the class EzySocketClient method connectTo.
public void connectTo(String host, int port) {
EzySocketStatus status = socketStatuses.last();
if (!isSocketConnectable(status)) {
EzyLogger.warn("socket is connecting...");
return;
}
this.socketStatuses.push(EzySocketStatus.CONNECTING);
this.host = host;
this.port = port;
this.reconnectCount = 0;
this.connect0(0);
}
Aggregations