comet help

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

comet help

minh13_o
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.

Minh


Climb to the top of the charts!  Play Star Shuffle:  the word scramble challenge with star power. Play Now!
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

CometChat2.java (8K) Download Attachment
CometChatHandler.java (2K) Download Attachment
chat.html (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

FW: comet help

minh13_o
My apologies if this is a repost.


From: [hidden email]
To: [hidden email]
CC: [hidden email]; [hidden email]
Subject: comet help
Date: Sun, 14 Oct 2007 00:25:07 +0000

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.

Minh


Climb to the top of the charts!  Play Star Shuffle:  the word scramble challenge with star power. Play Now!


Help yourself to FREE treats served up daily at the Messenger Café. Stop by today!
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

CometChat2.java (8K) Download Attachment
CometChatHandler.java (2K) Download Attachment
chat.html (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: comet help

Jeanfrancois Arcand-2
In reply to this post by minh13_o
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: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: comet help

minh13_o
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: [hidden email]
> Subject: Re: comet help
> To: [hidden email]
> CC: [hidden email]
>
> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]


Climb to the top of the charts!  Play Star Shuffle:  the word scramble challenge with star power. Play Now!
Reply | Threaded
Open this post in threaded view
|

Re: comet help

Jeanfrancois Arcand-2
Hi Minh,

The problem seems to be related to the hash code used to notify the
second client. I suspect line 56:

int hashCode = context.addCometHandler(handler);

is not called when you invoke the sendMessage(....):

int hashCode = handler.hashCode();
context.notify(message, CometEvent.NOTIFY, hashCode);

this is probably line 158 that produce the exception. Internally, what
it does is:

>     443     public void notify(final E attachment,final int eventType,final int cometHandlerID)
>     444             throws IOException{
>     445         CometHandler cometHandler = getCometHandler(cometHandlerID);
>     446
>     447         if (cometHandler == null){
>     448             throw new IllegalStateException(INVALID_COMET_HANDLER);
>     449         }

Here the getCometHandler() will return null if the addCometHandler
hasn't been invoked previously. Can you double check your CometHandler
has been added?

You code looks good (and you seems to use the non blocking read/write,
which is something I still need to blog on :-) You will beat me on those
features :-) :-)

Thanks!

-- Jeanfrancois



Minh O wrote:

> Hi Jeanfrancois,
>
> I'm using glassfish-installer-v2-b58g-windows
> <http://java.net/download/javaee5/v2_branch/promoted/WINNT/glassfish-installer-v2-b58g.jar>
>
> 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: [hidden email]
>  > Subject: Re: comet help
>  > To: [hidden email]
>  > CC: [hidden email]
>  >
>  > 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: [hidden email]
>  > > For additional commands, e-mail: [hidden email]
>
> ------------------------------------------------------------------------
> 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>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: comet help

minh13_o

So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up.  I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);" in the handler because from looking at the code it removes it from the map?ThanksMinh> Date: Mon, 15 Oct 2007 20:06:52 -0400> From: [hidden email]> Subject: Re: comet help> To: [hidden email]> CC: [hidden email]> > Hi Minh,> > The problem seems to be related to the hash code used to notify the > second client. I suspect line 56:> > int hashCode = context.addCometHandler(handler);> > is not called when you invoke the sendMessage(....):> > int hashCode = handler.hashCode();> context.notify(message, CometEvent.NOTIFY, hashCode);> > this is probably line 158 that produce the exception. Internally, what > it does is:> > >     443     public void notify(final E attachment,final int eventType,final int cometHandlerID)> >     444             throws IOException{> >     445         CometHandler cometHandler = getCometHandler(cometHandlerID);> >     446 > >     447         if (cometHandler == null){> >     448             throw new IllegalStateException(INVALID_COMET_HANDLER);> >     449         }> > Here the getCometHandler() will return null if the addCometHandler > hasn't been invoked previously. Can you double check your CometHandler > has been added?> > You code looks good (and you seems to use the non blocking read/write, > which is something I still need to blog on :-) You will beat me on those > features :-) :-)> > Thanks!> > -- Jeanfrancois> > > > Minh O wrote:> > Hi Jeanfrancois,> > > > I'm using glassfish-installer-v2-b58g-windows > > <http://java.net/download/javaee5/v2_branch/promoted/WINNT/glassfish-installer-v2-b58g.jar>> > > > 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: [hidden email]> >  > Subject: Re: comet help> >  > To: [hidden email]> >  > CC: [hidden email]> >  >> >  > 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: [hidden email]> >  > > For additional commands, e-mail: [hidden email]> > > > ------------------------------------------------------------------------> > 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>
_________________________________________________________________
Peek-a-boo FREE Tricks & Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: comet help

Jeanfrancois Arcand-2
Hi Minh,

Minh O wrote:
> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up.  I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"


You only need to invoke the resumeCometHandler if you want to resume the
suspended connection. That might be the problem then...usually, you
suspend the connection by calling addCometHandler(), and resume it using
resumeComentHandler(). Do you need to resume it or can it be expired by
Grizzly itself using the CometContent.setExpirationDelay() value?


in the handler because from looking at the code it removes it from the
map?ThanksMinh>

Yes you are right. So you probably don't want to call it :-)

Thanks

-- Jeanfrancois

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: comet help

minh13_o

Hi Jeanfrancois,

If I understand correctly, when you add a handler, it suspends the thread.  When I want to send a message back to the client, I need to resume the handler by calline resumCometHandler(this)?  If this is the case, then I must call it before writing anything to the stream?.  Will that keep the http connection alive from the server to the client?

I set the expiration time to be 1hr if that makes a difference.

Thanks for replying so late.  I'll be cracking at it tonight and let you know how I fair tomorrow...fingers crossed.

Thanks,
Minh


> Date: Mon, 15 Oct 2007 20:59:11 -0400
> From: [hidden email]
> Subject: Re: comet help
> To: [hidden email]
> CC: [hidden email]
>
> Hi Minh,
>
> Minh O wrote:
>> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up. I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"
>
>
> You only need to invoke the resumeCometHandler if you want to resume the
> suspended connection. That might be the problem then...usually, you
> suspend the connection by calling addCometHandler(), and resume it using
> resumeComentHandler(). Do you need to resume it or can it be expired by
> Grizzly itself using the CometContent.setExpirationDelay() value?
>
>
> in the handler because from looking at the code it removes it from the
> map?ThanksMinh>
>
> Yes you are right. So you probably don't want to call it :-)
>
> Thanks
>
> -- Jeanfrancois

_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: comet help

Jeanfrancois Arcand-2
Hi Minh,

Minh O wrote:
> Hi Jeanfrancois,
>
> If I understand correctly, when you add a handler, it suspends the thread.  When I want to send a message back to the client, I need to resume the handler by calline resumCometHandler(this)?  

No you don't. The CometContext.notify() will take care of resuming and
suspending the connection again.Only when you want to resume the
connection (bring it backto a synchronous connection) that you need to
call resumeCometHandler(). So I suspect you shouldn't call it :-) and
let the 1 hour expiration happens....

Thanks

-- Jeanfrancois

If this is the case, then I must call it before writing anything to the
stream?.  Will that keep the http connection alive from the server to
the client?

>
> I set the expiration time to be 1hr if that makes a difference.
>
> Thanks for replying so late.  I'll be cracking at it tonight and let you know how I fair tomorrow...fingers crossed.
>
> Thanks,
> Minh
>
>
>> Date: Mon, 15 Oct 2007 20:59:11 -0400
>> From: [hidden email]
>> Subject: Re: comet help
>> To: [hidden email]
>> CC: [hidden email]
>>
>> Hi Minh,
>>
>> Minh O wrote:
>>> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up. I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"
>>
>> You only need to invoke the resumeCometHandler if you want to resume the
>> suspended connection. That might be the problem then...usually, you
>> suspend the connection by calling addCometHandler(), and resume it using
>> resumeComentHandler(). Do you need to resume it or can it be expired by
>> Grizzly itself using the CometContent.setExpirationDelay() value?
>>
>>
>> in the handler because from looking at the code it removes it from the
>> map?ThanksMinh>
>>
>> Yes you are right. So you probably don't want to call it :-)
>>
>> Thanks
>>
>> -- Jeanfrancois
>
> _________________________________________________________________
> Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: comet help

minh13_o

Hi Jeanfrancois,

I think I figured out one of the problems.  ExtJS framework for ajax request has a timeout.  I noticed last night that after putting some logging statements in onInterrupt and on onTerminated, the onInterrupt method was being invoked after 20sec~ or so.  I checked the documentation for Ext.Ajax.request and there is a default timeout of 30sec.  Close to what I was experiencing so today I'll try setting the timeout to a large number and work out sending the json message to the client.

Thanks for the help.  Once I get this done, I'd be more than happy to put up a tutorial on building a servlet and client side for the curious.  Just let me know if there are any guidelines to that.

Minh

> Date: Tue, 16 Oct 2007 07:57:31 -0400
> From: [hidden email]
> To: [hidden email]
> Subject: Re: comet help
>
> Hi Minh,
>
> Minh O wrote:
>> Hi Jeanfrancois,
>>
>> If I understand correctly, when you add a handler, it suspends the thread. When I want to send a message back to the client, I need to resume the handler by calline resumCometHandler(this)?
>
> No you don't. The CometContext.notify() will take care of resuming and
> suspending the connection again.Only when you want to resume the
> connection (bring it backto a synchronous connection) that you need to
> call resumeCometHandler(). So I suspect you shouldn't call it :-) and
> let the 1 hour expiration happens....
>
> Thanks
>
> -- Jeanfrancois
>
> If this is the case, then I must call it before writing anything to the
> stream?. Will that keep the http connection alive from the server to
> the client?
>>
>> I set the expiration time to be 1hr if that makes a difference.
>>
>> Thanks for replying so late. I'll be cracking at it tonight and let you know how I fair tomorrow...fingers crossed.
>>
>> Thanks,
>> Minh
>>
>>
>>> Date: Mon, 15 Oct 2007 20:59:11 -0400
>>> From: [hidden email]
>>> Subject: Re: comet help
>>> To: [hidden email]
>>> CC: [hidden email]
>>>
>>> Hi Minh,
>>>
>>> Minh O wrote:
>>>> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up. I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"
>>>
>>> You only need to invoke the resumeCometHandler if you want to resume the
>>> suspended connection. That might be the problem then...usually, you
>>> suspend the connection by calling addCometHandler(), and resume it using
>>> resumeComentHandler(). Do you need to resume it or can it be expired by
>>> Grizzly itself using the CometContent.setExpirationDelay() value?
>>>
>>>
>>> in the handler because from looking at the code it removes it from the
>>> map?ThanksMinh>
>>>
>>> Yes you are right. So you probably don't want to call it :-)
>>>
>>> Thanks
>>>
>>> -- Jeanfrancois
>>
>> _________________________________________________________________
>> Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
>> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: comet help

Jeanfrancois Arcand-2
Hi Minh,

Minh O wrote:
> Hi Jeanfrancois,
>
> I think I figured out one of the problems.  ExtJS framework for ajax request has a timeout.  I noticed last night that after putting some logging statements in onInterrupt and on onTerminated, the onInterrupt method was being invoked after 20sec~ or so.  I checked the documentation for Ext.Ajax.request and there is a default timeout of 30sec.  Close to what I was experiencing so today I'll try setting the timeout to a large number and work out sending the json message to the client.
>

did you figure it out? I'm interested to learn if ExtJS can work with
Grizzly Comet properly.

> Thanks for the help.  Once I get this done, I'd be more than happy to put up a tutorial on building a servlet and client side for the curious.  Just let me know if there are any guidelines to that.
>

A tutorial kind of document like this one:

https://grizzly.dev.java.net/tutorials/connection-cache/index.html

would be quite appreciated if you have time, of course :-)

A+

-- Jeanfrancois



> Minh
>> Date: Tue, 16 Oct 2007 07:57:31 -0400
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: comet help
>>
>> Hi Minh,
>>
>> Minh O wrote:
>>> Hi Jeanfrancois,
>>>
>>> If I understand correctly, when you add a handler, it suspends the thread. When I want to send a message back to the client, I need to resume the handler by calline resumCometHandler(this)?
>> No you don't. The CometContext.notify() will take care of resuming and
>> suspending the connection again.Only when you want to resume the
>> connection (bring it backto a synchronous connection) that you need to
>> call resumeCometHandler(). So I suspect you shouldn't call it :-) and
>> let the 1 hour expiration happens....
>>
>> Thanks
>>
>> -- Jeanfrancois
>>
>> If this is the case, then I must call it before writing anything to the
>> stream?. Will that keep the http connection alive from the server to
>> the client?
>>> I set the expiration time to be 1hr if that makes a difference.
>>>
>>> Thanks for replying so late. I'll be cracking at it tonight and let you know how I fair tomorrow...fingers crossed.
>>>
>>> Thanks,
>>> Minh
>>>
>>>
>>>> Date: Mon, 15 Oct 2007 20:59:11 -0400
>>>> From: [hidden email]
>>>> Subject: Re: comet help
>>>> To: [hidden email]
>>>> CC: [hidden email]
>>>>
>>>> Hi Minh,
>>>>
>>>> Minh O wrote:
>>>>> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up. I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"
>>>> You only need to invoke the resumeCometHandler if you want to resume the
>>>> suspended connection. That might be the problem then...usually, you
>>>> suspend the connection by calling addCometHandler(), and resume it using
>>>> resumeComentHandler(). Do you need to resume it or can it be expired by
>>>> Grizzly itself using the CometContent.setExpirationDelay() value?
>>>>
>>>>
>>>> in the handler because from looking at the code it removes it from the
>>>> map?ThanksMinh>
>>>>
>>>> Yes you are right. So you probably don't want to call it :-)
>>>>
>>>> Thanks
>>>>
>>>> -- Jeanfrancois
>>> _________________________________________________________________
>>> Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
>>> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> _________________________________________________________________
> Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it now.
> http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: comet help

minh13_o
I had a hard time getting anything to work so I stripped everything out and went to the basics.  Created my own xmlhttprequest object and went from there.  I will try again with extjs but I think it doesn't support the open http session that I need it too.  I believe dojo is the only js framework that supports cometd type communication and maybe dwr?.  Got a simple open session push to finally work.  Currently working on the js framework for the chat system.  Once I get that done, I'll make another one for you that you can use as a demo.  Exciting stuff...can't wait to get a prototype working :)

I'll also try to get you that document as well.  I know I had a pretty big initial learning curve to get things working so I can feel for everyone else out there that are banging their heads against the wall like I did.

One more question, is there a way to test the suspend thread connection?  I like to see the performance gain by not doing a thread-wait type approach.

Thanks,
Minh

> Date: Thu, 18 Oct 2007 08:08:46 -0400
> From: [hidden email]
> To: [hidden email]
> Subject: Re: comet help
>
> Hi Minh,
>
> Minh O wrote:
> > Hi Jeanfrancois,
> >
> > I think I figured out one of the problems. ExtJS framework for ajax request has a timeout. I noticed last night that after putting some logging statements in onInterrupt and on onTerminated, the onInterrupt method was being invoked after 20sec~ or so. I checked the documentation for Ext.Ajax.request and there is a default timeout of 30sec. Close to what I was experiencing so today I'll try setting the timeout to a large number and work out sending the json message to the client.
> >
>
> did you figure it out? I'm interested to learn if ExtJS can work with
> Grizzly Comet properly.
>
> > Thanks for the help. Once I get this done, I'd be more than happy to put up a tutorial on building a servlet and client side for the curious. Just let me know if there are any guidelines to that.
> >
>
> A tutorial kind of document like this one:
>
> https://grizzly.dev.java.net/tutorials/connection-cache/index.html
>
> would be quite appreciated if you have time, of course :-)
>
> A+
>
> -- Jeanfrancois
>
>
>
> > Minh
> >> Date: Tue, 16 Oct 2007 07:57:31 -0400
> >> From: [hidden email]
> >> To: [hidden email]
> >> Subject: Re: comet help
> >>
> >> Hi Minh,
> >>
> >> Minh O wrote:
> >>> Hi Jeanfrancois,
> >>>
> >>> If I understand correctly, when you add a handler, it suspends the thread. When I want to send a message back to the client, I need to resume the handler by calline resumCometHandler(this)?
> >> No you don't. The CometContext.notify() will take care of resuming and
> >> suspending the connection again.Only when you want to resume the
> >> connection (bring it backto a synchronous connection) that you need to
> >> call resumeCometHandler(). So I suspect you shouldn't call it :-) and
> >> let the 1 hour expiration happens....
> >>
> >> Thanks
> >>
> >> -- Jeanfrancois
> >>
> >> If this is the case, then I must call it before writing anything to the
> >> stream?. Will that keep the http connection alive from the server to
> >> the client?
> >>> I set the expiration time to be 1hr if that makes a difference.
> >>>
> >>> Thanks for replying so late. I'll be cracking at it tonight and let you know how I fair tomorrow...fingers crossed.
> >>>
> >>> Thanks,
> >>> Minh
> >>>
> >>>
> >>>> Date: Mon, 15 Oct 2007 20:59:11 -0400
> >>>> From: [hidden email]
> >>>> Subject: Re: comet help
> >>>> To: [hidden email]
> >>>> CC: [hidden email]
> >>>>
> >>>> Hi Minh,
> >>>>
> >>>> Minh O wrote:
> >>>>> So I thought that might be the case in that regards but the hashcode is correct because I print the hashcode on handler add and the hashcode on message send and they both match up. I'll do more testing tonight to see if I made a mistake because that is a likely candidate so hopefully I find something tonight.Also, do I need the "event.getCometContext().resumeCometHandler(this);"
> >>>> You only need to invoke the resumeCometHandler if you want to resume the
> >>>> suspended connection. That might be the problem then...usually, you
> >>>> suspend the connection by calling addCometHandler(), and resume it using
> >>>> resumeComentHandler(). Do you need to resume it or can it be expired by
> >>>> Grizzly itself using the CometContent.setExpirationDelay() value?
> >>>>
> >>>>
> >>>> in the handler because from looking at the code it removes it from the
> >>>> map?ThanksMinh>
> >>>>
> >>>> Yes you are right. So you probably don't want to call it :-)
> >>>>
> >>>> Thanks
> >>>>
> >>>> -- Jeanfrancois
> >>> _________________________________________________________________
> >>> Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
> >>> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >
> > _________________________________________________________________
> > Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now.
> > http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now!