0 Replies Latest reply on Nov 13, 2009 7:56 AM by Cr99

    consumer retry until subscribe successful

    Cr99 Level 1

      I need to communicate with over a BlazeDS channel, but I can't guarantee the producer will be up when I launch the app.  Instead I want it to keep trying to connect until the producer comes online.  Here's the code I have, but it never establishes the subscription:


      public function startConnectionAttempts():void {

      consumer.addEventListener(ChannelEvent.DISCONNECT, reconnect);

      consumeTimer = new Timer(2000);

      consumeTimer.addEventListener(TimerEvent.TIMER, attemptSubscribe);





      // keep attempting to subscribe until successful

      public function attemptSubscribe(event:TimerEvent):void {

      if (consumer.subscribed) {

      Alert.show("Subscribed","Stop Timer");

      consumeTimer.removeEventListener(TimerEvent.TIMER, attemptSubscribe);



      else consumer.subscribe();