Package flex.messaging.messages

Examples of flex.messaging.messages.CommandMessage


        // 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();
View Full Code Here


        // Push a disconnect command down to the client to suppress automatic reconnect.
        if (disconnectChannel)
        {
            ArrayList<AsyncMessage> list = new ArrayList<AsyncMessage>(1);
            CommandMessage disconnect = new CommandMessage(CommandMessage.DISCONNECT_OPERATION);
            list.add(disconnect);
            pushMessages(list);           
        }

        // Invalidate associated subscriptions; this doesn't attempt to notify the client.
View Full Code Here

        attemptingInvalidationClientNotification = notifyClient;
       
        // Build a subscription invalidation message and push to the client if it is still valid.
        if (notifyClient && flexClient != null && flexClient.isValid())
        {               
            CommandMessage msg = new CommandMessage();
            msg.setDestination(destination.getId());
            msg.setClientId(clientId);
            msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
            Set subscriberIds = new TreeSet();
            subscriberIds.add(clientId);
            try
            {
                ((MessageService)destination.getService()).pushMessageToClients(destination, subscriberIds, msg, false /* don't eval selector */);
            }
            catch (MessageException ignore) {}
        }       
       
        // Notify messageClientDestroyed listeners that we're being invalidated.
        if (destroyedListeners != null && !destroyedListeners.isEmpty())
        {
            for (Iterator iter = destroyedListeners.iterator(); iter.hasNext();)
            {
                ((MessageClientListener)iter.next()).messageClientDestroyed(this);               
            }
            destroyedListeners.clear();
        }

        // And generate unsubscribe messages for all of the MessageClient's subscriptions and
        // route them to the destination this MessageClient is subscribed to.
        // The reason we send a message to the service rather than just going straight to the SubscriptionManager
        // is that some adapters manage their own subscription state (i.e. JMS) in addition to us keeping track of
        // things with our SubscriptionManager.
        ArrayList unsubMessages = new ArrayList();
        synchronized (lock)
        {
            for (Iterator iter = subscriptions.iterator(); iter.hasNext();)
            {
                SubscriptionInfo subInfo = (SubscriptionInfo)iter.next();
                CommandMessage unsubMessage = new CommandMessage();
                unsubMessage.setDestination(destination.getId());
                unsubMessage.setClientId(clientId);
                unsubMessage.setOperation(CommandMessage.UNSUBSCRIBE_OPERATION);
                unsubMessage.setHeader(CommandMessage.SUBSCRIPTION_INVALIDATED_HEADER, Boolean.TRUE);
                unsubMessage.setHeader(CommandMessage.SELECTOR_HEADER, subInfo.selector);
                unsubMessage.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, subInfo.subtopic);
                unsubMessages.add(unsubMessage);
            }
        }
        // Release the lock and send the unsub messages.
        for (Iterator iter = unsubMessages.iterator(); iter.hasNext();)
View Full Code Here

        this.password = password;
        this.context = context;
    }

    public SoapUIAMFConnection login() throws ClientStatusException, ServerStatusException {
        CommandMessage commandMessage = createLoginCommandMessage();

        SoapUIAMFConnection amfConnection = new SoapUIAMFConnection();
        amfConnection.connect(endpoint);
        amfConnection.call((SubmitContext) context, null, commandMessage);
        logedIn = true;
View Full Code Here

        return amfConnection;
    }

    public static void logout(SubmitContext context) {
        SoapUIAMFConnection connection = (SoapUIAMFConnection) context.getProperty(AMFSubmit.AMF_CONNECTION);
        CommandMessage commandMessage = createLogoutCommandMessage();
        try {
            connection.call((SubmitContext) context, null, commandMessage);
        } catch (ClientStatusException e) {
            SoapUI.logError(e);
        } catch (ServerStatusException e) {
View Full Code Here

        }
    }

    public void logout() {
        SoapUIAMFConnection connection = (SoapUIAMFConnection) context.getProperty(AMFSubmit.AMF_CONNECTION);
        CommandMessage commandMessage = createLogoutCommandMessage();
        try {
            connection.call((SubmitContext) context, null, commandMessage);
        } catch (ClientStatusException e) {
            SoapUI.logError(e);
        } catch (ServerStatusException e) {
View Full Code Here

            connection.close();
        }
    }

    private CommandMessage createLoginCommandMessage() {
        CommandMessage commandMessage = new CommandMessage();
        commandMessage.setOperation(CommandMessage.LOGIN_OPERATION);

        String credString = username + ":" + password;
        Encoder encoder = new Encoder(credString.length());
        encoder.encode(credString.getBytes());

        commandMessage.setBody(encoder.drain());
        commandMessage.setDestination(DESTINATION);
        return commandMessage;
    }
View Full Code Here

        commandMessage.setDestination(DESTINATION);
        return commandMessage;
    }

    private static CommandMessage createLogoutCommandMessage() {
        CommandMessage commandMessage = new CommandMessage();
        commandMessage.setOperation(CommandMessage.LOGOUT_OPERATION);
        commandMessage.setDestination(DESTINATION);
        return commandMessage;
    }
View Full Code Here

                                    // If the MessageClient isn't attempting client notification, override
                                    // and do so in this case to suppress the next poll request from the remote client
                                    // which will fail triggering an unnecessary channel disconnect on the client.
                                    if (!messageClient.isAttemptingInvalidationClientNotification())
                                    {
                                        CommandMessage msg = new CommandMessage();
                                        msg.setClientId(messageClient.getClientId());
                                        msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
                                        List messages = flushResult.getMessages();
                                        if (messages == null)
                                            messages = new ArrayList(1);
                                        messages.add(msg);
                                    }
View Full Code Here

                    }
                    FlushResult flushResult = client.getFlexClient().poll(client);
                    List messagesToReturn = (flushResult != null) ? flushResult.getMessages() : null;
                    if (messagesToReturn != null && !messagesToReturn.isEmpty())
                    {
                        replyMessage = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
                        replyMessage.setBody(messagesToReturn.toArray());
                    }
                    else
                    {
                        replyMessage = new AcknowledgeMessage();
View Full Code Here

TOP

Related Classes of flex.messaging.messages.CommandMessage

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.