Handles the received {@link Packet} on the client. Closes the GUI.

@param message the message
@param ctx the ctx
763627
@Override
	public void process(Packet message, MessageContext ctx)
	{
		if (MalisisGui.current() != null)
			MalisisGui.current().close();
	}
981844
@Override
    public void sendFailure(String message) {
        System.out.print("Warning: " + message);
        System.exit(1);
    }
1121537
private void handlePacket(Stanza packet) {
        if (packet instanceof Message) {
            Message msg = (Message) packet;
            // Check to see if the user left the queue.
            ExtensionElement pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup");
            ExtensionElement queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup");

            if (pe != null) {
                fireQueueDepartedEvent();
            }
            else if (queueStatus != null) {
                QueueUpdate queueUpdate = (QueueUpdate) queueStatus;
                if (queueUpdate.getPosition() != -1) {
                    fireQueuePositionEvent(queueUpdate.getPosition());
                }
                if (queueUpdate.getRemaingTime() != -1) {
                    fireQueueTimeEvent(queueUpdate.getRemaingTime());
                }
            }

            else {
                // Check if a room invitation was sent and if the sender is the workgroup
                MUCUser mucUser = msg.getExtension("x", "http://jabber.org/protocol/muc#user");
                MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
                if (invite != null && workgroupJID.equals(invite.getFrom())) {
                    String sessionID = null;
                    Map<String, List<String>> metaData = null;

                    pe = msg.getExtension(SessionID.ELEMENT_NAME,
                            SessionID.NAMESPACE);
                    if (pe != null) {
                        sessionID = ((SessionID) pe).getSessionID();
                    }

                    pe = msg.getExtension(MetaData.ELEMENT_NAME,
                            MetaData.NAMESPACE);
                    if (pe != null) {
                        metaData = ((MetaData) pe).getMetaData();
                    }

                    WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(),
                            workgroupJID, sessionID, msg.getBody(),
                            msg.getFrom(), metaData);

                    fireInvitationEvent(inv);
                }
            }
        }
    }
1119929
private void send( String message ) {

		if( ! this.enabled.get()) {
			this.logger.finest( "Notifications were disabled by the DM." );

		} else if( message == null ) {
			this.logger.finest( "No message to send to web socket clients." );

		} else synchronized( SESSIONS ) {
			for( Session session : SESSIONS ) {
				try {
					this.logger.finest( "Sending a message to a web socket client..." );
					session.getRemote().sendString( message );

				} catch( IOException e ) {
					StringBuilder sb = new StringBuilder( "A notification could not be propagated for session " );
					sb.append( session.getRemoteAddress());
					sb.append( "." );
					if( ! Utils.isEmptyOrWhitespaces( e.getMessage()))
						sb.append( " " + e.getMessage());

					this.logger.severe( sb.toString());
					Utils.logException( this.logger, e );
				}
			}
		}
	}
779980
public void sendTextMessage(String message) {
		MessageEnvelope envelope = new MessageEnvelope();
		ReceivedMessage body = new ReceivedMessage();

		body.setText(message);
		envelope.setMessage(body);
		envelope.setSender(new User(facebookMockId));

		System.out.println("Sending message: [" + message + "] as user : ["
				+ facebookMockId + "].");
		forward(envelope);
		System.out.println("Sent!");
	}
762266
public void handleMessageReceived(Packet packet) {
        if (log.isTraceEnabled()) {
            log.trace("handleMessageReceived - {}", sessionId);
        }
        // set the packet expiration time if maxHandlingTimeout is not disabled (set to 0)
        if (maxHandlingTimeout > 0) {
            packet.setExpirationTime(System.currentTimeMillis() + maxHandlingTimeout);
        }
        if (executor != null) {
            final byte dataType = packet.getHeader().getDataType();
            // route these types outside the executor
            switch (dataType) {
                case Constants.TYPE_PING:
                case Constants.TYPE_ABORT:
                case Constants.TYPE_BYTES_READ:
                case Constants.TYPE_CHUNK_SIZE:
                case Constants.TYPE_CLIENT_BANDWIDTH:
                case Constants.TYPE_SERVER_BANDWIDTH:
                    // pass message to the handler
                    try {
                        handler.messageReceived(this, packet);
                    } catch (Exception e) {
                        log.error("Error processing received message {}", sessionId, e);
                    }
                    break;
                default:
                    final String messageType = getMessageType(packet);
                    try {
                        // increment the packet number
                        final long packetNumber = packetSequence.incrementAndGet();
                        if (executorQueueSizeToDropAudioPackets > 0 && currentQueueSize.get() >= executorQueueSizeToDropAudioPackets) {
                            if (packet.getHeader().getDataType() == Constants.TYPE_AUDIO_DATA) {
                                // if there's a backlog of messages in the queue. Flash might have sent a burst of messages after a network congestion. Throw away packets that we are able to discard.
                                log.info("Queue threshold reached. Discarding packet: session=[{}], msgType=[{}], packetNum=[{}]", sessionId, messageType, packetNumber);
                                return;
                            }
                        }
                        int streamId = packet.getHeader().getStreamId().intValue();
                        if (log.isTraceEnabled()) {
                            log.trace("Handling message for streamId: {}, channelId: {} Channels: {}", streamId, packet.getHeader().getChannelId(), channels);
                        }
                        // create a task to setProcessing the message
                        ReceivedMessageTask task = new ReceivedMessageTask(sessionId, packet, handler, this);
                        task.setPacketNumber(packetNumber);
                        // create a task queue
                        ReceivedMessageTaskQueue newStreamTasks = new ReceivedMessageTaskQueue(streamId, this);
                        // put the queue in the task by stream map
                        ReceivedMessageTaskQueue currentStreamTasks = tasksByStreams.putIfAbsent(streamId, newStreamTasks);
                        if (currentStreamTasks != null) {
                            // add the task to the existing queue
                            currentStreamTasks.addTask(task);
                        } else {
                            // add the task to the newly created and just added queue
                            newStreamTasks.addTask(task);
                        }
                    } catch (Exception e) {
                        log.error("Incoming message handling failed on session=[" + sessionId + "], messageType=[" + messageType + "]", e);
                        if (log.isDebugEnabled()) {
                            log.debug("Execution rejected on {} - {}", sessionId, RTMP.states[getStateCode()]);
                            log.debug("Lock permits - decode: {} encode: {}", decoderLock.availablePermits(), encoderLock.availablePermits());
                        }
                    }
            }
        } else {
            log.debug("Executor is null on {} state: {}", sessionId, RTMP.states[getStateCode()]);
            // pass message to the handler
            try {
                handler.messageReceived(this, packet);
            } catch (Exception e) {
                log.error("Error processing received message {} state: {}", sessionId, RTMP.states[getStateCode()], e);
            }
        }
    }
1207967
private void handleChannelCallback(final String message) {
		// Channel callback
		updateConnectionHeartbeat();

		// JSON callback
		final JSONArray jsonArray = new JSONArray(new JSONTokener(message));

		if(connectionFeatureManager.isConnectionFeatureActive(BitfinexConnectionFeature.SEQ_ALL)) {
			sequenceNumberAuditor.auditPackage(jsonArray);
		}

		final int channel = jsonArray.getInt(0);
		final ChannelCallbackHandler channelCallbackHandler = channelIdToHandlerMap.get(channel);
		if (channelCallbackHandler == null) {
			logger.error("Unable to determine symbol for channel {} / data is {} ", channel, jsonArray);
			reconnect();
			return;
		}
		String action = null;
		final JSONArray payload;
		if (jsonArray.get(1) instanceof String) {
			action = jsonArray.getString(1);
			payload = jsonArray.optJSONArray(2);
		} else {
			payload = jsonArray.optJSONArray(1);
		}
		if (Objects.equals(action, "hb")) {
			quoteManager.updateChannelHeartbeat(channelCallbackHandler.getSymbol());
		}
		try {
			if (payload == null) {
				return;
			}
			channelCallbackHandler.handleChannelData(action, payload);
		} catch (final BitfinexClientException e) {
			logger.error("Got exception while handling callback", e);
		}
	}
932681
private void writeEvent(final ChannelHandlerContext ctx, final Object message) {
        if (isFinishedSent)
            return;
        
        if (message instanceof FinishedMessage)
            isFinishedSent = true;

        Channels.write(ctx, Channels.future(null), message);
    }
630029
def on_message(self, opcode, message):
		
		self.logger.debug("processing {0} (opcode: 0x{1:02x}) message".format(self._opcode_names.get(opcode, 'UNKNOWN'), opcode))
		if opcode == self._opcode_close:
			self.close()
		elif opcode == self._opcode_ping:
			if len(message) > 125:
				self.close()
				return
			self.send_message(self._opcode_pong, message)
		elif opcode == self._opcode_pong:
			pass
		elif opcode == self._opcode_binary:
			self.on_message_binary(message)
		elif opcode == self._opcode_text:
			try:
				message = self._decode_string(message)
			except UnicodeDecodeError:
				self.logger.warning('closing connection due to invalid unicode within a text message')
				self.close()
			else:
				self.on_message_text(message)
		elif opcode == self._opcode_continue:
			self.close()
		else:
			self.logger.warning("received unknown opcode: {0} (0x{0:02x})".format(opcode))
			self.close()
613351
public int handleMessage(BaseMessage message)
    {
        Utility.getLogger().info("RemoteQueue handling message " + message);
        if (message.getProcessedByClientSession() == this.getParentSession())
            return DBConstants.NORMAL_RETURN;     // Do not process this message (the client has already taken care of it).
//?        if (message.getProcessedByClientSession() instanceof RemoteObject)
//?            if (this.getParentSession() instanceof RemoteObject) // Always
//?                if (((RemoteObject)this.getParentSession()).getRef().remoteEquals(((RemoteObject)message.getProcessedByClientSession()).getRef()))
//?                    return DBConstants.NORMAL_RETURN;   // Same client.
        if (message == m_messageLastMessage)
            return DBConstants.NORMAL_RETURN;   // Don't send a message to the same client twice.
        m_messageLastMessage = message;
        this.getMessageStack().sendMessage(message);
        return DBConstants.NORMAL_RETURN;
    }
817855
public void onMessage(final byte[] message, final Session session) {
        final SynchronizeFXWebsocketChannel channel = getChannelOrFail(session);

        channel.newMessage(message, session);
    }
276591
protected void handleMessage(@NonNull VoidMessage message) {
        if (message == null) {
            //            log.info("sI_{} got null message", getShardIndex());
            return;
        }

        if (message.getTargetId() >= 0 && message.getTargetId() != shardIndex) {
            log.warn("sI_{}: Skipping message: [{}]; TargetIdx: [{}]", shardIndex, message.getClass().getSimpleName(),
                            message.getTargetId());
            return;
        }

        //      log.info("sI_{}: Processing message: [{}]", shardIndex, message.getClass().getSimpleName());

        message.attachContext(voidConfiguration, trainer, clipboard, transport, storage, nodeRole, shardIndex);
        message.processMessage();
    }
1026724
public synchronized void onReceive(final Packet packet, final Client client) throws IOException
    {
        if (globalHandler != null) globalHandler.onReceive(packet, client);

        final PacketHandler packetHandler = registry.get(packet.getPacketID());
        if (packetHandler == null)
        {
            if (defaultHandler != null) defaultHandler.handlePacket(packet, client);
        }
        else packetHandler.handlePacket(packet, client);
    }
1321249
public void sendMessage(final String message) {
        try {
            session.sendMessage(new TextMessage(message));
        }
        catch (IOException e) {
            logger.error("[sendTextMessage]", e);
        }
    }
769235
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
        if (frame instanceof CloseWebSocketFrame) {
            this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
            CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler))
                    .thenAcceptAsync(this.handler::onDisConnect);
            return;
        }
        if (frame instanceof PingWebSocketFrame) {
            ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
            return;
        }

        if (!(frame instanceof TextWebSocketFrame)) {
            throw new UnsupportedOperationException("unsupported frame type: " + frame.getClass().getName());
        }
        CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler,((TextWebSocketFrame) frame).text()))
                .thenAcceptAsync(this.handler::onText,ctx.executor());
    }
1258669
@Override
    public void handleMessage(Message message) {

        handlersList = getHanderList(busType, flow);

        if (handlersList == null || handlersList.size() == 0) {

            return;
        }

        ArrayList<Handler> excutedHandlers = new ArrayList<Handler>();
        JAXRS20MessageContextImpl jaxrsMessageContext = new JAXRS20MessageContextImpl(message);
        jaxrsMessageContext.isServerSide = busType.equals(Type.SERVER);
        jaxrsMessageContext.isClientSide = busType.equals(Type.CLIENT);
        jaxrsMessageContext.setProperty(HandlerConstants.FLOW_TYPE, flow.toUpperCase());
        try {
            Iterator<Handler> it = handlersList.iterator();
            while (it.hasNext()) {
                Handler handler = it.next();
                handler.handleMessage(jaxrsMessageContext);
                excutedHandlers.add(handler);
            }
        } catch (Exception e) {
            for (int i = excutedHandlers.size() - 1; i >= 0; i--) {
                excutedHandlers.get(i).handleFault(jaxrsMessageContext);
            }
        }
    }
584515
@Override
  public void handlerRemoved(final ChannelHandlerContext ctx) throws Exception {
    if (responseContent != null && responseContent.refCnt() > 0) {
      responseContent.release();
      responseContent = null;
    }
  }