users@grizzly.java.net

RE: comet help

From: Minh O <minh13_o_at_hotmail.com>
Date: Mon, 15 Oct 2007 16:04:46 +0000

Hi Jeanfrancois,

I'm using glassfish-installer-v2-b58g-windows

For the part where the resume is happening, I assume that you are refering to

"//event.getCometContext().resumeCometHandler(this);"

That was in originally but I didn't work for me so I commented it out and add the these 2 lines below it and that still didn't work so I left them all commented out.

"//event.getCometContext().registerAsyncRead(this);
 //event.getCometContext().registerAsyncWrite(this);"

Thanks for responding so quickly, you probably get tons of emails for help. Once I get this working, I'd like to post a tutorial on this as I think it would be a great example and provide a lot of insight to how it works.

Thanks again,

Minh

> Date: Mon, 15 Oct 2007 09:50:01 -0400
> From: Jeanfrancois.Arcand_at_Sun.COM
> Subject: Re: comet help
> To: users_at_grizzly.dev.java.net
> CC: minh13_o_at_hotmail.com
>
> Hi Minh,
>
>
>
>
> Minh O wrote:
> > Hi Jeanfrancois,
> >
> > I've been trying to implement a chat program where a user can send a
> > message to his/her buddies. I've implemented it so that there are only
> > 2 people that can send messages to each other but when I send a post to
> > forward to a user, I get this message.
> >
> > 'java.lang.IllegalStateException: CometHandler cannot be null. This
> > CometHandler
> > was probably resumed and an invalid reference was made to it.'
> >
> > Below is the code that is invoked to forward the message to the user.
> >
> > {code}
> > public void sendMessage(Message message, CometHandler handler) {
> >
> > if(handler != null) {
> > try {
> > CometEngine engine = CometEngine.getEngine();
> > CometContext context =
> > engine.getCometContext(CHAT_CONTEXT_PATH);
> > int hashCode = handler.hashCode();
> > sLogger.info('[CometChat2]\tSending message to: ' +
> > message.getTo()
> > + ' from: ' + message.getFrom() + ' handler
> > hashcode: ' + hashCode);
> > context.notify(message, CometEvent.NOTIFY, hashCode);
> > } catch (IOException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > }
> > } else {
> > sLogger.severe('[CometChat]\tHandler is null for sending
> > message to: ' + message.getTo());
> > }
> > }
> > {code}
> >
> >
> > This is what is in the CometHandler implementation.
> > {code}
> > @Override
> > public void onEvent(CometEvent event) throws IOException {
> > // TODO Auto-generated method stub
> > sLogger.info('[CometChatHandler]\tEvent type is: ' +
> > event.getType());
> > if(event.getType() == CometEvent.NOTIFY) {
> > Object obj = event.attachment();
> >
> > if(obj != null && obj instanceof Message) {
> > PrintWriter writer = response.getWriter();
> > writer.write(XStreamUtil.objectToJSON('jsonMSG', obj));
> > writer.flush();
> >
> > //event.getCometContext().resumeCometHandler(this);
> > //event.getCometContext().registerAsyncRead(this);
> > //event.getCometContext().registerAsyncWrite(this);
> >
> > } else {
> > sLogger.severe('[CometChatHandler]\tEvent attachment is
> > not a Message obj: ' + obj.getClass().getName());
> > }
> > }
> > }
> > {code}
> >
> > I've attach the servlet code and the handler code. If you could point
> > me to the right direction, it would be greatly appreciated.
>
> Hum...this is strange as your code that resume the CometHandler is
> commented out. Let me take a look . Are you using GlassFish or Grizzly
> standalone?
>
> Thanks
>
> -- Jeanfrancois
>
>
>
> >
> > Minh
> >
> > ------------------------------------------------------------------------
> > Climb to the top of the charts! Play Star Shuffle: the word scramble
> > challenge with star power. Play Now!
> > <http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct>
> > ------------------------------------------------------------------------
> >
> > Here is a simple AJAX Request.
> >
> >
> > ------------------------------------------------------------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> > For additional commands, e-mail: users-help_at_grizzly.dev.java.net

_________________________________________________________________
Climb to the top of the charts!  Play Star Shuffle:  the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct