Hi John,
John C. Turnbull wrote:
> I am not getting the exact behaviour I expected with the version of
> Grizzly that’s included in GlassFish v2 UR1 and looking at the code for
> Grizzly itself I see there are a couple of strange things. I realise
> that the code for the standalone Grizzly and that for Grizzly in GF may
> be a little different but in the standalone Grizzly there is a class
> CometContext with the following method:
>
>
>
> protected void notify(CometEvent event, int eventType, SelectionKey key)
Right, but the method is protected, so you cannot use it (it's for an
internal call).
>
>
>
> and it defines various event types. However, the body of the method
> does nothing with the event type so all events have the same (default)
> type. Is this intentional?
>
>
>
> Also, I have been trying to notify Comet events using this method by
> creating a new CometEvent<MyAttachment> and attaching an attachment of
> type MyAttachment. However, when I process the event in onEvent() of
> the CometHandler, the following code:
Hum are you sure you are using this method?
>
>
>
> System.out.println("Attachment is a " + event.attachment().getClass());
>
>
>
> prints out that the attachment is of type CometEvent and not
> MyAttachment as desired (and hence I can’t do anything with it). Does
> anyone know why this would be so?
>
>
>
> I am close to having Grizzly and GlassFish with Comet behaving as I want
> so it would be nice to finish things off.
You have 3 solutions:
(1) notify(Object attachment,int eventType) //
(NOTIFY|INITIALIZE|TERMINATE|INTERRUPT|READ);
Most of the time you only use the NOTIFY.
(2) notify(Object attachmenent);
same as above, but it force a NOTIFY event.
(3) notify(Object attachment,int eventType,int cometHandlerHash);
same as (1), but this time you can specify which cometHandler you want
to notify instead of all of them.
In you case (1) is what you are looking at. Can you try it and let me know?
Thanks
-- Jeanfrancois
>
>
>
> Thanks,
>
>
>
> -JCT
>
>
>