-
1. Re: Comet 8kb limit
jfclere Nov 28, 2011 4:39 AM (in response to emersonpardo)if the write blocs you have to use event.isWriteReady() to test if you can write and if not wait for the WRITE event.
-
2. Re: Comet 8kb limit
emersonpardo Nov 28, 2011 6:51 AM (in response to jfclere)Hi Jean-Frederic! Thanks for the response.
I followed the initial example and put all the write processing inside a thread like MessageSender and the events are triggered inside HttpServletEvent. Is there any example explaning how to use event.isWriteReady() out there?
Thanks again!
-
3. Re: Comet 8kb limit
jfclere Nov 29, 2011 2:37 AM (in response to emersonpardo)1 of 1 people found this helpfulI am using something like:
while (event.isWriteReady()) {
os.println("bla");
}
and I have a logic in the case WRITE
switch (event.getType()) {
....
case WRITE:
/* write more ? */
break;
-
4. Re: Comet 8kb limit
emersonpardo Nov 29, 2011 7:38 AM (in response to jfclere)Jean-Frederic,
I'll try this and post here if it works.
Thanks!
Jean-Frederic Clere wrote:
I am using something like:
while (event.isWriteReady()) {
os.println("bla");
}
and I have a logic in the case WRITE
switch (event.getType()) {
....
case WRITE:
/* write more ? */
break;
-
5. Re: Comet 8kb limit
emersonpardo Nov 29, 2011 3:14 PM (in response to emersonpardo)It's worked!
My code look like the following, inside my thread I have to do this:
private Semaphore sem = new Semaphore(0);
void writeMessage(String message){
byte[] msg = message.getBytes();
for(byte b:msg){
if(!event.isWriteReady())
sem.acquire();
writer.write(b);
}
}
void notifyWrite(){
sem.release();
}
}
And insite HttpServletEvent in the case WRITE:
case WRITE:
myThread.notifyWrite();
Thanks for the help, Jean-Frederic.
Emerson Pardo wrote:
Jean-Frederic,
I'll try this and post here if it works.
Thanks!
Jean-Frederic Clere wrote:
I am using something like:
while (event.isWriteReady()) {
os.println("bla");
}
and I have a logic in the case WRITE
switch (event.getType()) {
....
case WRITE:
/* write more ? */
break;