[android-developers] Smack xmpp / Handler question

2010-10-07 Thread Federico Paolinelli
Have anybody tried it?
I am doing some experiments, and I saw that:

- connect / login are executed in the same thread of the caller, then
are blocking
- The packetlistener callbacks are called from smack receiver thread
- The sendpacket enqueues the message to a queue

Now my question: when I receive a message, I need to propagate it. I
can use an handler, but it only gets the runnable object. How can I
pass the data to the runnable called by the handler?

I can't use a local variabile, because if I receive a lot of messages
it will be overridden and I will loose some of them. Is it ok to use a
queue to feed the runnable? Are there other techniques?

Thanks and regards,

Federico

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Smack xmpp / Handler question

2010-10-07 Thread Kostya Vasilyev

 Put the data into the instance of Runnable subclass you pass to handler.

Something like this:

private static class WorkerRunnable implements Runnable {
ToastRunnable(data goes here) {
mData1 = data1;
mData2 = data2;
...
}

@Override
public void run() {
mData1, mData2 are accessible here
}

private Object mData1;
private Object mData2;

}

And then:

mHandler.post(new WorkerRunnable (data1, data2, ));

-- Kostya

07.10.2010 16:27, Federico Paolinelli пишет:

Have anybody tried it?
I am doing some experiments, and I saw that:

- connect / login are executed in the same thread of the caller, then
are blocking
- The packetlistener callbacks are called from smack receiver thread
- The sendpacket enqueues the message to a queue

Now my question: when I receive a message, I need to propagate it. I
can use an handler, but it only gets the runnable object. How can I
pass the data to the runnable called by the handler?

I can't use a local variabile, because if I receive a lot of messages
it will be overridden and I will loose some of them. Is it ok to use a
queue to feed the runnable? Are there other techniques?

Thanks and regards,

 Federico




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Smack xmpp / Handler question

2010-10-07 Thread Federico Paolinelli
Thanks a lot.

Federico

On Thu, Oct 7, 2010 at 2:36 PM, Kostya Vasilyev kmans...@gmail.com wrote:
  Put the data into the instance of Runnable subclass you pass to handler.

 Something like this:

 private static class WorkerRunnable implements Runnable {
 ToastRunnable(data goes here) {
 mData1 = data1;
 mData2 = data2;
 ...
 }

 @Override
 public void run() {
 mData1, mData2 are accessible here
 }

 private Object mData1;
 private Object mData2;
 
 }

 And then:

 mHandler.post(new WorkerRunnable (data1, data2, ));

 -- Kostya

 07.10.2010 16:27, Federico Paolinelli пишет:

 Have anybody tried it?
 I am doing some experiments, and I saw that:

 - connect / login are executed in the same thread of the caller, then
 are blocking
 - The packetlistener callbacks are called from smack receiver thread
 - The sendpacket enqueues the message to a queue

 Now my question: when I receive a message, I need to propagate it. I
 can use an handler, but it only gets the runnable object. How can I
 pass the data to the runnable called by the handler?

 I can't use a local variabile, because if I receive a lot of messages
 it will be overridden and I will loose some of them. Is it ok to use a
 queue to feed the runnable? Are there other techniques?

 Thanks and regards,

     Federico



 --
 Kostya Vasilyev -- WiFi Manager + pretty widget --
 http://kmansoft.wordpress.com

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 

Federico

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en