Skip to content

Commit

Permalink
Minor improvements before release
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Mar 18, 2017
1 parent 3074cb5 commit 573263a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void addCLoseDetectListener(Channel _channel) {
}
});
}catch (Exception e){
LOGGER.error("Error while connection to the server: ",e);
doConnect();
}
}
public void shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mercury.platform.core.update.core.holder.ApplicationHolder;
import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.events.MercuryEventHandler;
import com.mercury.platform.shared.events.custom.*;
import com.mercury.platform.update.UpdateDescriptor;
import com.mercury.platform.update.UpdateType;
Expand All @@ -26,11 +27,16 @@ public class ClientHandler extends SimpleChannelInboundHandler<Object> {
private volatile int length;
private volatile int percentDelta;
private ResponseDispatcher responseDispatcher;
private MercuryEventHandler<CheckOutPatchNotes> checkOutPatchNotesHandler;
private MercuryEventHandler<StartUpdateEvent> startUpdateEventHandler;

private ChannelHandlerContext context;
public ClientHandler() {
chunks = new byte[0];
responseDispatcher = new ResponseDispatcher();

checkOutPatchNotesHandler = event -> checkOutPatchNotes();
startUpdateEventHandler = event -> getLatestUpdate();
}

@Override
Expand Down Expand Up @@ -64,12 +70,8 @@ public void channelActive(ChannelHandlerContext context) throws Exception {
Integer version = ApplicationHolder.getInstance().getVersion();
context.channel().writeAndFlush(new UpdateDescriptor(UpdateType.REQUEST_INFO, version));
}
EventRouter.CORE.registerHandler(CheckOutPatchNotes.class, handler -> {
checkOutPatchNotes();
});
EventRouter.CORE.registerHandler(StartUpdateEvent.class, handler -> {
getLatestUpdate();
});
EventRouter.CORE.registerHandler(CheckOutPatchNotes.class, checkOutPatchNotesHandler);
EventRouter.CORE.registerHandler(StartUpdateEvent.class, startUpdateEventHandler);
}
}
private void checkOutPatchNotes(){
Expand All @@ -91,11 +93,16 @@ private void getLatestUpdate(){
@Override
public void channelInactive(ChannelHandlerContext context) throws Exception {
LOGGER.info("Channel is inactive");
EventRouter.CORE.unregisterHandler(CheckOutPatchNotes.class, checkOutPatchNotesHandler);
EventRouter.CORE.unregisterHandler(StartUpdateEvent.class, startUpdateEventHandler);

}

@Override
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) throws Exception {
LOGGER.error(Arrays.toString(cause.getStackTrace()));
EventRouter.CORE.unregisterHandler(CheckOutPatchNotes.class, checkOutPatchNotesHandler);
EventRouter.CORE.unregisterHandler(StartUpdateEvent.class, startUpdateEventHandler);
LOGGER.error(cause);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ public void registerHandler(Class eventClass, MercuryEventHandler handler){
eventHandlerMap.put(eventClass, mercuryEventHandlers);
lock.unlock();
}
public void unregisterHandler(Class eventClass, MercuryEventHandler handler){
lock.lock();
List<MercuryEventHandler> mercuryEventHandlers = eventHandlerMap.get(eventClass);
mercuryEventHandlers.remove(handler);
eventHandlerMap.put(eventClass, mercuryEventHandlers);
lock.unlock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TooltipConstants {
public static final String HO_OUT = "Travel to your hideout";


public static final String IS_IT_QUAD = "todo";
public static final String IS_IT_QUAD = "Is this tab a Quad Tab? Specify once for Mercury to know";

//History tooltips
public static final String HISTORY_CLEAR = "Clear history";
Expand Down

0 comments on commit 573263a

Please sign in to comment.