Great! I was about to post a code snippet, but you were too fast on this
one ;)
Anyway, here is the code (should definitely be documented):
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = new GravityChannel("gravityamf", "
http://127.0.0.1:8080/chat/gravity/amf");
channelSet.addChannel(channel);
var consumer:Consumer = new Consumer();
consumer.destination = "gravity";
consumer.topic = "discussion";
consumer.channelSet = channelSet;
consumer.subscribe();
consumer.addEventListener(MessageEvent.MESSAGE, messageHandler);
var producer:Producer = new Producer();
producer.destination = "gravity";
producer.channelSet = channelSet;
producer.topic = "discussion";
Franck.
2013/8/27 Massimo Perani <[email protected]>
> Hi Franck,
> I found this topic:
> https://groups.google.com/forum/#!topic/graniteds/Z2qv5mSHqDQ
>
> where Murray write about your email and explains how to
> set the channel of the consumer
>
> consumer.channelSet.addChannel(new GravityChannel("gravityamf",
> "http://{server.name}:{server.port}/myapp/gravityamf/amf"));
>
> I solved all my Gravity problem, now I can fly in the air... :-)
>
> Thanks so much for your help.
> Massimo.
>
>
> 2013/8/27 Massimo Perani <[email protected]>
>
> > Thank you guys, you are right!
> > I entered "localhost" in the "Flex Server / Server Location" field of
> > Flash Builder compiler option.
> > Now replacing localhost with the ip the problem was solved.
> > Sorry but I had never considered this parameter because with RemoteObject
> > I always set the endpoint by code.
> >
> > Can I ask you if is possible to do the same thing with Gravity?
> > So that my application are able to connect to different URLs depending by
> > the environment
> > (development / production).
> >
> > Thanks so much for your help.
> > Massimo.
> >
> >
> > 2013/8/27 Franck Wolff <[email protected]>
> >
> >> I'm pretty sure this is an issue with the settings of your Air mobile
> >> application / Simulator. Did you enable networking (eg.
> >> android:permission.INTERNET)? Can you access anything outside your Air
> >> application (try with a simple remote call, use a web view and try to
> load
> >> google web page, etc.) Make sure also that your emulator isn't using a
> >> special IP for localhost (as Pedro suggested): the Android simulator
> uses
> >> a
> >> specific IP (10.0.2.2) for localhost (your desktop server), see:
> >>
> >>
> http://blogs.adobe.com/jtalbot/2010/12/07/accessing-localhost-from-the-android-emulator/
> >> .
> >>
> >> Franck.
> >>
> >>
> >>
> >> 2013/8/27 Massimo Perani <[email protected]>
> >>
> >> > Hi Pedro,
> >> > thanks for your suggestion,
> >> > but the AIR simulator is running locally on the same host of my
> backend
> >> > (localhost).
> >> > I replaced localhost with the IP following your suggestion, but with
> the
> >> > same result.
> >> > The WEB project works and the MOBILE not...
> >> >
> >> > I'm probably forgetting some other simple things
> >> > but I don't understand which one
> >> > :-)
> >> >
> >> > Thanks
> >> > Massimo
> >> >
> >> >
> >> > 2013/8/27 Pedro Serralha <[email protected]>
> >> >
> >> > > Hi there
> >> > >
> >> > > Are you using localhost on your request url?
> >> > > If so on the mobile app you are pointing into your own mobile phone,
> >> and
> >> > > I'm
> >> > > positive that the services aren't running on your phone.
> >> > > It should work on the web project since, I assume is where the
> >> services
> >> > are
> >> > > running.
> >> > >
> >> > > Try to use the IP of your machine.
> >> > >
> >> > > Maybe this is a silly point to say, but sometimes we forgot the
> >> simplest
> >> > > things.
> >> > >
> >> > >
> >> > > Cumprimentos / Best Regards
> >> > > Pedro Serralha
> >> > >
> >> > > -----Original Message-----
> >> > > From: Massimo Perani [mailto:[email protected]]
> >> > > Sent: terça-feira, 27 de Agosto de 2013 10:23
> >> > > To: [email protected]
> >> > > Subject: Re: Help with GraniteDS GRAVITY and Flex MOBILE Chat
> >> Application
> >> > >
> >> > > Hi Franck,
> >> > > thanks for your answer.
> >> > >
> >> > > Yes, I set the channel in the services-config.xml but I can't see
> any
> >> > > calls...
> >> > > I'm using the same services-config.xml for for both the web version
> >> and
> >> > the
> >> > > mobile version.
> >> > >
> >> > >
> >> > > Is there a way to force the endpoint of a gravity consumer from code
> >> at
> >> > > runtime?
> >> > > Like RemoteObject used with graniteamf (eg: ro.endpoint="
> >> > > http://localhost:8080/myapp/graniteamf/amf")
> >> > > so something like that:
> >> > > consumer.endpoint="http://localhost:8080/myapp/gravity/amf";
> >> > >
> >> > >
> >> > > Is there a way to trace the network calls from the AIR simulator?
> >> > > In the WEB version of my app (the one that works) I can use the
> >> Network
> >> > tab
> >> > > of the Chrome Developer tool, and I can see the post call to the
> >> Gravity
> >> > > Servlet:
> >> > >
> >> > > 1. Request URL:
> >> > > http://localhost:8080/myapp/gravity/amf?m=1377594866363
> >> > >
> >> > >
> >> > > Thanks
> >> > > Massimo.
> >> > >
> >> > >
> >> > >
> >> > > 2013/8/27 Franck Wolff <[email protected]>
> >> > >
> >> > > > Strange... I can't see anything that would prevent Gravity working
> >> > > > with a Air mobile application (it's regular long-polling HTTP,
> >> nothing
> >> > > special).
> >> > > >
> >> > > > Make sure you have an explicit URL to your backend in your
> >> > > > services-config.xml file (ie. no placeholder such as
> >> > > > {server.name}:{server.port}/{context.root},
> >> > > > it must be a valid and explicit <IP/domain>:<port>/<webapp> URL).
> >> > > >
> >> > > > Franck.
> >> > > >
> >> > > >
> >> > > > 2013/8/27 Massimo Perani <[email protected]>
> >> > > >
> >> > > > > Hi all,
> >> > > > > I'm doing some tests with Gravity (GraniteDS), my goal is to
> >> create
> >> > > > > a
> >> > > > chat
> >> > > > > module for my application.
> >> > > > >
> >> > > > > Everything works correctly if I use Gravity in a Flex WEB
> Project
> >> > > > > (so the flex app runs in the browser).
> >> > > > >
> >> > > > > If I create a Flex MOBILE project I can't see any call to the
> >> > > > > Gravity servlet but I have no errors in the flex application.
> >> > > > >
> >> > > > > I can't find anything about Gravity specific for Flex MOBILE, Is
> >> > > > > there anyone who can give me some suggestion?
> >> > > > >
> >> > > > > I'm using FB 4.7, Apache flex 4.10.0, GraniteDS 3.0.0.M3.
> >> > > > > i'm using a Java Spring Backend running on Tomcat 7 with NIO
> >> > > > > protocol set on connector
> >> > > > >
> >> > > > > Thanks to all
> >> > > > >
> >> > > > > --
> >> > > > > Massimo Perani
> >> > > > >
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > Massimo Perani
> >> > >
> >> > >
> >> >
> >> >
> >> > --
> >> > Massimo Perani
> >> >
> >>
> >
> >
> >
> > --
> > Massimo Perani
> >
>
>
>
> --
> Massimo Perani
>