public void setProtocol(ProtocolType protocol) { getChannel().flush(); GlowProtocol proto = protocol.getProtocol(); updatePipeline("codecs", new CodecsHandler(proto)); super.setProtocol(proto); }
@Override public void messageReceived(Message message) { if (message instanceof AsyncableMessage && ((AsyncableMessage) message).isAsync()) { // async messages get their handlers called immediately super.messageReceived(message); } else { messageQueue.add(message); } }
/** Pulse this session, performing any updates needed. */ void pulse() { // drop the previous placement if needed if (previousPlacementTicks > 0 && --previousPlacementTicks == 0) { previousPlacement = null; } // process messages Message message; while ((message = messageQueue.poll()) != null) { if (disconnected) { // disconnected, we are just seeing extra messages now continue; } super.messageReceived(message); } // check if the client is disconnected if (disconnected) { connectionManager.sessionInactivated(this); if (player == null) { return; } player.remove(); Message userListMessage = UserListItemMessage.removeOne(player.getUniqueId()); for (GlowPlayer player : server.getOnlinePlayers()) { if (player.canSee(this.player)) { player.getSession().send(userListMessage); } else { player.stopHidingDisconnectedPlayer(this.player); } } GlowServer.logger.info(player.getName() + " [" + address + "] lost connection"); if (player.isSleeping()) { player.leaveBed(false); } final String text = EventFactory.onPlayerQuit(player).getQuitMessage(); if (online && text != null && !text.isEmpty()) { server.broadcastMessage(text); } player = null; // in case we are disposed twice } }