Hi,
At a AsyncTask subclass, you could do as the followings. But please keep in
mind that I'm not a Android developer so I'm sure the doInBackground is the
best place to create zeromq context.
This is an example which create a worker thread then the worker thread
communicate outside as a pure ZMQ application and communicate with Android
through a pipe.
If your requirement is simple, you could do your stuff without creating new
thread as many other examples in the ZMQ guide.
@Override
protected Integer doInBackground (String... args)
{
ZContext ctx = new ZContext ();
ctx.setLinger (100);
Socket pipe = ZThread.fork (ctx, new Worker(), args[0]);
Poller poller = ctx.getContext ().poller ();
poller.register (pipe, Poller.POLLIN);
while (!Thread.currentThread ().isInterrupted ()) {
if (poller.poll (1000) < 0)
break;
if (poller.pollin (0)) {
String message = pipe.recvStr ();
publishProgress (message);
}
pipe.send ("HELLO");
}
ctx.destroy ();
return null;
}
Thanks
Min
On Jun 13, 2013, at 11:12 PM, ashwini ramamurthy <[email protected]>
wrote:
>
> Hi,
>
> Thanks for the quick response. Is there any example android application using
> jeromq I could refer ?
>
> Thanks,
> Ashwini
> On Thu, Jun 13, 2013 at 4:02 AM, Pieter Hintjens <[email protected]> wrote:
> You may find that JeroMQ is easier to use on Android.
>
> -Pieter
>
> On Wed, Jun 12, 2013 at 6:14 PM, ashwini ramamurthy
> <[email protected]> wrote:
> > Hi,
> >
> > I want to use ZeroMQ in my android application. I have built ZeroMQ along
> > with JZMQ and its JAR. I wanted to run a simple client server application in
> > android with zeromq. Is there any example I could refer to?
> >
> >
> > Thanks in advance
> >
> >
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > [email protected]
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev