Package flex.messaging.messages

Examples of flex.messaging.messages.Message


     */
    public Message convertToSmallMessage(Message message)
    {
        if (message instanceof SmallMessage)
        {
            Message smallMessage = ((SmallMessage)message).getSmallMessage();
            if (smallMessage != null)
                message = smallMessage;
        }

        return message;
View Full Code Here


        if (isManaged())
        {
            ((EndpointControl) getControl()).incrementServiceMessageCount();
        }

        Message ack = null;

        // Make sure this message is timestamped.
        if (message.getTimestamp() == 0)
        {
            message.setTimestamp(System.currentTimeMillis());
        }
       
        // Reset the endpoint header for inbound messages to the id for this endpoint
        // to guarantee that it's correct. Don't allow clients to spoof this.
        // However, if the endpoint id is passed as null we need to tag the message to
        // skip channel/endpoint validation at the destination level (MessageBroker.inspectChannel()).
        if (message.getHeader(Message.ENDPOINT_HEADER) != null)
            message.setHeader(Message.VALIDATE_ENDPOINT_HEADER, Boolean.TRUE);
        message.setHeader(Message.ENDPOINT_HEADER, getId());       
               
        if (message instanceof CommandMessage)
        {
            CommandMessage command = (CommandMessage)message;
           
            // Apply channel endpoint level constraint; always allow login commands through.
            if (command.getOperation() != CommandMessage.LOGIN_OPERATION)
                checkSecurityConstraint(message);
           
            // Handle general (not Consumer specific) poll requests here.
            // We need to fetch all outbound messages for client subscriptions over this endpoint.
            // We identify these general poll messages by their operation and a null clientId.           
            int operation = command.getOperation();
            if (operation == CommandMessage.POLL_OPERATION && message.getClientId() == null)
            {
                verifyFlexClientSupport(command);
               
               
                FlexClient flexClient = FlexContext.getFlexClient();
                ack = handleFlexClientPollCommand(flexClient, command);                                                                                           
            }
            else if (operation == CommandMessage.DISCONNECT_OPERATION)
            {
                ack = handleChannelDisconnect(command);
            }
            else
            {
                // Block a subset of commands for legacy clients that need to be recompiled to
                // interop with a 2.5+ server.
                if (operation == CommandMessage.SUBSCRIBE_OPERATION || operation == CommandMessage.POLL_OPERATION)
                    verifyFlexClientSupport(command);
               
                ack = getMessageBroker().routeCommandToService((CommandMessage) message, this);

                // Look for client advertised features on initial connect.
                if (operation == CommandMessage.CLIENT_PING_OPERATION || operation == CommandMessage.LOGIN_OPERATION)
                {
                    Number clientVersion = (Number)command.getHeader(CommandMessage.MESSAGING_VERSION);
                    handleClientMessagingVersion(clientVersion);

                    // Also respond by advertising the messaging version on the
                    // acknowledgement.
                    ack.setHeader(CommandMessage.MESSAGING_VERSION, new Double(messagingVersion));
                }
            }
        }
        else
        {                      
View Full Code Here

            Log.getLogger(getMessageBroker().getLogCategory(pollCommand)).debug(
                 "Before handling general client poll request. " + StringUtils.NEWLINE +
                 "  incomingMessage: " + pollCommand + StringUtils.NEWLINE);

        FlushResult flushResult = handleFlexClientPoll(flexClient, pollCommand);
        Message pollResponse = null;
       
        // Generate a no-op poll response if necessary; prevents a single client from busy polling when the server
        // is doing wait()-based long-polls.
        if ((flushResult instanceof PollFlushResult) && ((PollFlushResult)flushResult).isClientProcessingSuppressed())
        {
            pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
            pollResponse.setHeader(CommandMessage.NO_OP_POLL_HEADER, Boolean.TRUE);
        }
       
        if (pollResponse == null)
        {
            List messagesToReturn = (flushResult != null) ? flushResult.getMessages() : null;
            if (messagesToReturn != null && !messagesToReturn.isEmpty())
            {
                pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
                pollResponse.setBody(messagesToReturn.toArray());
            }
            else
            {
                pollResponse = new AcknowledgeMessage();
            }
        }
           
        // Set the adaptive poll wait time if necessary.
        if (flushResult != null)
        {
            int nextFlushWaitTime = flushResult.getNextFlushWaitTimeMillis();
            if (nextFlushWaitTime > 0)
                pollResponse.setHeader(CommandMessage.POLL_WAIT_HEADER, new Integer(nextFlushWaitTime));                  
        }
           
        if (Log.isDebug())
        {
            String debugPollResult = Log.getPrettyPrinter().prettify(pollResponse);
View Full Code Here

TOP

Related Classes of flex.messaging.messages.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.