Meteor and jQuery Plugin

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Meteor and jQuery Plugin

Cagatay Civici
Hi,

I'm trying to use meteorservlet and jquery plugin together and can't figure out what's wrong;

Test case is simple, whenever a client connects,

Servlet
public class ListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Meteor meteor = Meteor.build(req);

        req.getSession().setAttribute("meteor", meteor);

        meteor.suspend(-1);

        meteor.broadcast("Connected:" + req.getHeader("user-agent"));
    }
}

Mapping
<servlet>
        <servlet-name>Meteor Servlet</servlet-name>
        <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.servlet</param-name>
            <param-value>org.primefaces.examples.ListServlet</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Meteor Servlet</servlet-name>
        <url-pattern>/meteor/*</url-pattern>
</servlet-mapping>

And a client side code;

function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
       function(response) { alert("Response Received:" + response.responseBody); },
      { });
 }

I was expecting to get broadcasted message "Connected {user-agent}" on my callback as response.responseBody but nothing happens although doGet is executed as I've checked.

Cagatay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Jeanfrancois Arcand-4
Salut,

On 11-03-25 4:45 AM, Cagatay Civici wrote:

> Hi,
>
> I'm trying to use meteorservlet and jquery plugin together and can't figure out what's wrong;
>
> Test case is simple, whenever a client connects,
>
> Servlet
> public class ListServlet extends HttpServlet {
>
>      @Override
>      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>          Meteor meteor = Meteor.build(req);
>
>          req.getSession().setAttribute("meteor", meteor);
>
>          meteor.suspend(-1);
>
>          meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>      }
> }
>
> Mapping
> <servlet>
>          <servlet-name>Meteor Servlet</servlet-name>
>          <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>          <init-param>
>              <param-name>org.atmosphere.servlet</param-name>
>              <param-value>org.primefaces.examples.ListServlet</param-value>
>          </init-param>
>      </servlet>
>      <servlet-mapping>
>          <servlet-name>Meteor Servlet</servlet-name>
>          <url-pattern>/meteor/*</url-pattern>
> </servlet-mapping>
>
> And a client side code;
>
> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>         function(response) { alert("Response Received:" + response.responseBody); },
>        { });
>   }
>
> I was expecting to get broadcasted message "Connected {user-agent}" on my callback as response.responseBody but nothing happens although doGet is executed as I've checked.

Can you print the broadcaster instance? The Atmosphere resource number
is probably 0 ... My guess is the connection is not yet suspended. Which
container are you using?

A+

- Jeanfrancois


>
> Cagatay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Cagatay Civici
Hi JF,

I'm still trying to warmup, it has been quite some time since I've last worked with Atmosphere.

I've added a AtmosphereResourceEventListener to see what's going on and suspend/broadcast part seems to be working fine;

> public class CounterServlet extends HttpServlet implements AtmosphereResourceEventListener {
>
>     public final static Logger logger = LoggerFactory.getLogger(CounterServlet.class);
>
>     @Override
>     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>         Meteor meteor = Meteor.build(req);
>
>         req.getSession().setAttribute("meteor", meteor);
>
>         meteor.addListener(this);
>
>         meteor.suspend(-1);
>
>         meteor.broadcast("Connected:" + req.getRemoteAddr());
>
>         logger.info("Connected:" + req.getRemoteAddr());
>         logger.info("Broadcaster:" + meteor.getBroadcaster());
>         logger.info("Resource:" + meteor.getAtmosphereResource());
>     }
>
>     public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Broadcasting " + event.getMessage());
>     }
>
>     public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Disconnected:" + event.getResource().getRequest().getRemoteAddr());
>     }
>
>     public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Resumed: " + event.getResource().getRequest().getRemoteAddr());
>     }
>
>     public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Suspended: " + event.getResource().getRequest().getRemoteAddr());
>     }
>
>     public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Throwed: " + event.getResource().getRequest().getRemoteAddr());
>     }
> }

First time I try to subscribe, the log is;

> 63 [qtp701905307-21] INFO org.atmosphere.cpr.AtmosphereServlet - started atmosphere framework: 0.7
> 80 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Suspended: 0:0:0:0:0:0:0:1%0
> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Connected:0:0:0:0:0:0:0:1%0
> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Broadcaster:org.atmosphere.cpr.DefaultBroadcaster@1108628844
>         Name: /*
>         Scope: APPLICATION
>         BroasdcasterCache org.atmosphere.cpr.BroadcasterConfig$DefaultBroadcasterCache@44f44758
>         AtmosphereResource: 1


Finally the container I've tried with are jetty 6 and 8.0.M2, result is same;

> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response) { alert("Response Received:" + response.responseBody); }, {} );


My callback is not executed, the interesting part is, callback function is executed for all clients when I shutdown the server.

My question is with AtmosphereHandler, when a broadcast happens onStateChange is executed and we push the message with the response writer right? With Meteor, is just broadcasting the message enough?

Thanks for your time Jeanfrancois,

Cagatay

On Mar 25, 2011, at 3:07 PM, jfarcand wrote:

> Salut,
>
> On 11-03-25 4:45 AM, Cagatay Civici wrote:
>> Hi,
>>
>> I'm trying to use meteorservlet and jquery plugin together and can't figure out what's wrong;
>>
>> Test case is simple, whenever a client connects,
>>
>> Servlet
>> public class ListServlet extends HttpServlet {
>>
>>     @Override
>>     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>>         Meteor meteor = Meteor.build(req);
>>
>>         req.getSession().setAttribute("meteor", meteor);
>>
>>         meteor.suspend(-1);
>>
>>         meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>     }
>> }
>>
>> Mapping
>> <servlet>
>>         <servlet-name>Meteor Servlet</servlet-name>
>>         <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>>         <init-param>
>>             <param-name>org.atmosphere.servlet</param-name>
>>             <param-value>org.primefaces.examples.ListServlet</param-value>
>>         </init-param>
>>     </servlet>
>>     <servlet-mapping>
>>         <servlet-name>Meteor Servlet</servlet-name>
>>         <url-pattern>/meteor/*</url-pattern>
>> </servlet-mapping>
>>
>> And a client side code;
>>
>> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>>        function(response) { alert("Response Received:" + response.responseBody); },
>>       { });
>>  }
>>
>> I was expecting to get broadcasted message "Connected {user-agent}" on my callback as response.responseBody but nothing happens although doGet is executed as I've checked.
>
> Can you print the broadcaster instance? The Atmosphere resource number is probably 0 ... My guess is the connection is not yet suspended. Which container are you using?
>
> A+
>
> - Jeanfrancois
>
>
>>
>> Cagatay

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Jeanfrancois Arcand-4
Salut,

On 11-03-25 3:37 PM, Cagatay Civici wrote:

> Hi JF,
>
> I'm still trying to warmup, it has been quite some time since I've last worked with Atmosphere.
>
> I've added a AtmosphereResourceEventListener to see what's going on and suspend/broadcast part seems to be working fine;
>
>> public class CounterServlet extends HttpServlet implements AtmosphereResourceEventListener {
>>
>>      public final static Logger logger = LoggerFactory.getLogger(CounterServlet.class);
>>
>>      @Override
>>      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>>          Meteor meteor = Meteor.build(req);
>>
>>          req.getSession().setAttribute("meteor", meteor);
>>
>>          meteor.addListener(this);
>>
>>          meteor.suspend(-1);
>>
>>          meteor.broadcast("Connected:" + req.getRemoteAddr());
>>
>>          logger.info("Connected:" + req.getRemoteAddr());
>>          logger.info("Broadcaster:" + meteor.getBroadcaster());
>>          logger.info("Resource:" + meteor.getAtmosphereResource());
>>      }
>>
>>      public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Broadcasting " + event.getMessage());
>>      }
>>
>>      public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Disconnected:" + event.getResource().getRequest().getRemoteAddr());
>>      }
>>
>>      public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Resumed: " + event.getResource().getRequest().getRemoteAddr());
>>      }
>>
>>      public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Suspended: " + event.getResource().getRequest().getRemoteAddr());
>>      }
>>
>>      public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Throwed: " + event.getResource().getRequest().getRemoteAddr());
>>      }
>> }
>
> First time I try to subscribe, the log is;
>
>> 63 [qtp701905307-21] INFO org.atmosphere.cpr.AtmosphereServlet - started atmosphere framework: 0.7
>> 80 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Suspended: 0:0:0:0:0:0:0:1%0
>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Connected:0:0:0:0:0:0:0:1%0
>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet - Broadcaster:org.atmosphere.cpr.DefaultBroadcaster@1108628844
>>          Name: /*
>>          Scope: APPLICATION
>>          BroasdcasterCache org.atmosphere.cpr.BroadcasterConfig$DefaultBroadcasterCache@44f44758
>>          AtmosphereResource: 1
>
>
> Finally the container I've tried with are jetty 6 and 8.0.M2, result is same;
>
>> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response) { alert("Response Received:" + response.responseBody); }, {} );
>
>
> My callback is not executed, the interesting part is, callback function is executed for all clients when I shutdown the server.

That strange as it means the bytes are buffered in the socket and
flushed when socket gets closed.

>
> My question is with AtmosphereHandler, when a broadcast happens onStateChange is executed and we push the message with the response writer right?

Yes, onStateChange gets called.

  With Meteor, is just broadcasting the message enough?

It should as under the hood it does the same. The Meteor is really a
wrapper around an existing AtmosphereHandler.

Let me try to reproduce the issue locally.

A+

-- Jeanfrancois


>
> Thanks for your time Jeanfrancois,
>
> Cagatay
>
> On Mar 25, 2011, at 3:07 PM, jfarcand wrote:
>
>> Salut,
>>
>> On 11-03-25 4:45 AM, Cagatay Civici wrote:
>>> Hi,
>>>
>>> I'm trying to use meteorservlet and jquery plugin together and can't figure out what's wrong;
>>>
>>> Test case is simple, whenever a client connects,
>>>
>>> Servlet
>>> public class ListServlet extends HttpServlet {
>>>
>>>      @Override
>>>      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>>>          Meteor meteor = Meteor.build(req);
>>>
>>>          req.getSession().setAttribute("meteor", meteor);
>>>
>>>          meteor.suspend(-1);
>>>
>>>          meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>>      }
>>> }
>>>
>>> Mapping
>>> <servlet>
>>>          <servlet-name>Meteor Servlet</servlet-name>
>>>          <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>>>          <init-param>
>>>              <param-name>org.atmosphere.servlet</param-name>
>>>              <param-value>org.primefaces.examples.ListServlet</param-value>
>>>          </init-param>
>>>      </servlet>
>>>      <servlet-mapping>
>>>          <servlet-name>Meteor Servlet</servlet-name>
>>>          <url-pattern>/meteor/*</url-pattern>
>>> </servlet-mapping>
>>>
>>> And a client side code;
>>>
>>> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>>>         function(response) { alert("Response Received:" + response.responseBody); },
>>>        { });
>>>   }
>>>
>>> I was expecting to get broadcasted message "Connected {user-agent}" on my callback as response.responseBody but nothing happens although doGet is executed as I've checked.
>>
>> Can you print the broadcaster instance? The Atmosphere resource number is probably 0 ... My guess is the connection is not yet suspended. Which container are you using?
>>
>> A+
>>
>> - Jeanfrancois
>>
>>
>>>
>>> Cagatay
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Jeanfrancois Arcand-4
Salut,

the following works for me when I use AHC

>     public static class Meteor1 extends HttpServlet {
>         @Override
>         public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
>             final Meteor m = Meteor.build(req);
>             req.getSession().setAttribute("meteor", m);
>             m.suspend(-1);
>
>             m.broadcast("resume");
>             m.addListener(new AtmosphereResourceEventListener(){
>
>                 @Override
>                 public void onSuspend(final AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event){
>                 }
>
>                 @Override
>                 public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>                 }
>
>                 @Override
>                 public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>                 }
>
>                 @Override
>                 public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>                 }
>
>                 @Override
>                 public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>
>                 }
>             });
>
>             if (servletLatch != null) {
>                 servletLatch.countDown();
>             }
>         }
>     }

Can you send me your war so I can take a look?

Thanks!

-- Jeanfracnois


On 11-03-25 3:53 PM, jfarcand wrote:

> Salut,
>
> On 11-03-25 3:37 PM, Cagatay Civici wrote:
>> Hi JF,
>>
>> I'm still trying to warmup, it has been quite some time since I've
>> last worked with Atmosphere.
>>
>> I've added a AtmosphereResourceEventListener to see what's going on
>> and suspend/broadcast part seems to be working fine;
>>
>>> public class CounterServlet extends HttpServlet implements
>>> AtmosphereResourceEventListener {
>>>
>>> public final static Logger logger =
>>> LoggerFactory.getLogger(CounterServlet.class);
>>>
>>> @Override
>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>> resp) throws ServletException, IOException {
>>> Meteor meteor = Meteor.build(req);
>>>
>>> req.getSession().setAttribute("meteor", meteor);
>>>
>>> meteor.addListener(this);
>>>
>>> meteor.suspend(-1);
>>>
>>> meteor.broadcast("Connected:" + req.getRemoteAddr());
>>>
>>> logger.info("Connected:" + req.getRemoteAddr());
>>> logger.info("Broadcaster:" + meteor.getBroadcaster());
>>> logger.info("Resource:" + meteor.getAtmosphereResource());
>>> }
>>>
>>> public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest,
>>> HttpServletResponse> event) {
>>> logger.info("Broadcasting " + event.getMessage());
>>> }
>>>
>>> public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest,
>>> HttpServletResponse> event) {
>>> logger.info("Disconnected:" +
>>> event.getResource().getRequest().getRemoteAddr());
>>> }
>>>
>>> public void onResume(AtmosphereResourceEvent<HttpServletRequest,
>>> HttpServletResponse> event) {
>>> logger.info("Resumed: " +
>>> event.getResource().getRequest().getRemoteAddr());
>>> }
>>>
>>> public void onSuspend(AtmosphereResourceEvent<HttpServletRequest,
>>> HttpServletResponse> event) {
>>> logger.info("Suspended: " +
>>> event.getResource().getRequest().getRemoteAddr());
>>> }
>>>
>>> public void onThrowable(AtmosphereResourceEvent<HttpServletRequest,
>>> HttpServletResponse> event) {
>>> logger.info("Throwed: " +
>>> event.getResource().getRequest().getRemoteAddr());
>>> }
>>> }
>>
>> First time I try to subscribe, the log is;
>>
>>> 63 [qtp701905307-21] INFO org.atmosphere.cpr.AtmosphereServlet -
>>> started atmosphere framework: 0.7
>>> 80 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>> Suspended: 0:0:0:0:0:0:0:1%0
>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>> Connected:0:0:0:0:0:0:0:1%0
>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>> Broadcaster:org.atmosphere.cpr.DefaultBroadcaster@1108628844
>>> Name: /*
>>> Scope: APPLICATION
>>> BroasdcasterCache
>>> org.atmosphere.cpr.BroadcasterConfig$DefaultBroadcasterCache@44f44758
>>> AtmosphereResource: 1
>>
>>
>> Finally the container I've tried with are jetty 6 and 8.0.M2, result
>> is same;
>>
>>> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response)
>>> { alert("Response Received:" + response.responseBody); }, {} );
>>
>>
>> My callback is not executed, the interesting part is, callback
>> function is executed for all clients when I shutdown the server.
>
> That strange as it means the bytes are buffered in the socket and
> flushed when socket gets closed.
>
>>
>> My question is with AtmosphereHandler, when a broadcast happens
>> onStateChange is executed and we push the message with the response
>> writer right?
>
> Yes, onStateChange gets called.
>
> With Meteor, is just broadcasting the message enough?
>
> It should as under the hood it does the same. The Meteor is really a
> wrapper around an existing AtmosphereHandler.
>
> Let me try to reproduce the issue locally.
>
> A+
>
> -- Jeanfrancois
>
>
>>
>> Thanks for your time Jeanfrancois,
>>
>> Cagatay
>>
>> On Mar 25, 2011, at 3:07 PM, jfarcand wrote:
>>
>>> Salut,
>>>
>>> On 11-03-25 4:45 AM, Cagatay Civici wrote:
>>>> Hi,
>>>>
>>>> I'm trying to use meteorservlet and jquery plugin together and can't
>>>> figure out what's wrong;
>>>>
>>>> Test case is simple, whenever a client connects,
>>>>
>>>> Servlet
>>>> public class ListServlet extends HttpServlet {
>>>>
>>>> @Override
>>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>>> resp) throws ServletException, IOException {
>>>> Meteor meteor = Meteor.build(req);
>>>>
>>>> req.getSession().setAttribute("meteor", meteor);
>>>>
>>>> meteor.suspend(-1);
>>>>
>>>> meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>>> }
>>>> }
>>>>
>>>> Mapping
>>>> <servlet>
>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>> <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>>>> <init-param>
>>>> <param-name>org.atmosphere.servlet</param-name>
>>>> <param-value>org.primefaces.examples.ListServlet</param-value>
>>>> </init-param>
>>>> </servlet>
>>>> <servlet-mapping>
>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>> <url-pattern>/meteor/*</url-pattern>
>>>> </servlet-mapping>
>>>>
>>>> And a client side code;
>>>>
>>>> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>>>> function(response) { alert("Response Received:" +
>>>> response.responseBody); },
>>>> { });
>>>> }
>>>>
>>>> I was expecting to get broadcasted message "Connected {user-agent}"
>>>> on my callback as response.responseBody but nothing happens although
>>>> doGet is executed as I've checked.
>>>
>>> Can you print the broadcaster instance? The Atmosphere resource
>>> number is probably 0 ... My guess is the connection is not yet
>>> suspended. Which container are you using?
>>>
>>> A+
>>>
>>> - Jeanfrancois
>>>
>>>
>>>>
>>>> Cagatay
>>
>>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Cagatay Civici
Hi,

Here's an update, I thought default transport was websocket according to;

http://java.dzone.com/articles/using-atmospheres-jquery-plug

But jquery plugins uses long-polling as default, after changing to websocket my callback started to get executed.

> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response) { alert("Response Received:" + response.responseBody); }, {transport: 'websocket'} );

I still have a problem with long-polling though, changed my code to handle long-polling like below and callback is not executed.

> public class CounterServlet extends HttpServlet implements AtmosphereResourceEventListener {
>
>     public final static Logger logger = LoggerFactory.getLogger(CounterServlet.class);
>
>     @Override
>     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>         Meteor meteor = Meteor.build(req);
>
>         req.getSession().setAttribute("meteor", meteor);
>
>         meteor.addListener(this);
>
>         String transport = req.getHeader("X-Atmosphere-Transport");
>
>         meteor.suspend(-1, !(transport != null && transport.equalsIgnoreCase("long-polling")));
>
>         meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>     }
>
>     public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Broadcasting " + event.getMessage());
>
>         // If transport is long-polling, resume the connection when event is received.
>         String transport = event.getResource().getRequest().getHeader("X-Atmosphere-Transport");
>         if (transport != null && transport.equalsIgnoreCase("long-polling")) {
>             Meteor meteor = Meteor.lookup(event.getResource().getRequest());
>
>             meteor.removeListener(this);
>             meteor.resume();
>         }
>     }
>
>     public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Disconnected:" + event.getResource().getRequest().getHeader("user-agent"));
>     }
>
>     public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Resumed: " + event.getResource().getRequest().getHeader("user-agent"));
>     }
>
>     public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Suspended: " + event.getResource().getRequest().getHeader("user-agent"));
>     }
>
>     public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>         logger.info("Throwed: " + event.getResource().getRequest().getHeader("user-agent"));
>     }
> }

I'll prepare a simple war and send you Jeanfrancois, thanks very much again.

Cagatay

On Mar 25, 2011, at 10:03 PM, jfarcand wrote:

> Salut,
>
> the following works for me when I use AHC
>
>>    public static class Meteor1 extends HttpServlet {
>>        @Override
>>        public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
>>            final Meteor m = Meteor.build(req);
>>            req.getSession().setAttribute("meteor", m);
>>            m.suspend(-1);
>>
>>            m.broadcast("resume");
>>            m.addListener(new AtmosphereResourceEventListener(){
>>
>>                @Override
>>                public void onSuspend(final AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event){
>>                }
>>
>>                @Override
>>                public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>>                }
>>
>>                @Override
>>                public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>>                }
>>
>>                @Override
>>                public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>>                }
>>
>>                @Override
>>                public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>>
>>                }
>>            });
>>
>>            if (servletLatch != null) {
>>                servletLatch.countDown();
>>            }
>>        }
>>    }
>
> Can you send me your war so I can take a look?
>
> Thanks!
>
> -- Jeanfracnois
>
>
> On 11-03-25 3:53 PM, jfarcand wrote:
>> Salut,
>>
>> On 11-03-25 3:37 PM, Cagatay Civici wrote:
>>> Hi JF,
>>>
>>> I'm still trying to warmup, it has been quite some time since I've
>>> last worked with Atmosphere.
>>>
>>> I've added a AtmosphereResourceEventListener to see what's going on
>>> and suspend/broadcast part seems to be working fine;
>>>
>>>> public class CounterServlet extends HttpServlet implements
>>>> AtmosphereResourceEventListener {
>>>>
>>>> public final static Logger logger =
>>>> LoggerFactory.getLogger(CounterServlet.class);
>>>>
>>>> @Override
>>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>>> resp) throws ServletException, IOException {
>>>> Meteor meteor = Meteor.build(req);
>>>>
>>>> req.getSession().setAttribute("meteor", meteor);
>>>>
>>>> meteor.addListener(this);
>>>>
>>>> meteor.suspend(-1);
>>>>
>>>> meteor.broadcast("Connected:" + req.getRemoteAddr());
>>>>
>>>> logger.info("Connected:" + req.getRemoteAddr());
>>>> logger.info("Broadcaster:" + meteor.getBroadcaster());
>>>> logger.info("Resource:" + meteor.getAtmosphereResource());
>>>> }
>>>>
>>>> public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest,
>>>> HttpServletResponse> event) {
>>>> logger.info("Broadcasting " + event.getMessage());
>>>> }
>>>>
>>>> public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest,
>>>> HttpServletResponse> event) {
>>>> logger.info("Disconnected:" +
>>>> event.getResource().getRequest().getRemoteAddr());
>>>> }
>>>>
>>>> public void onResume(AtmosphereResourceEvent<HttpServletRequest,
>>>> HttpServletResponse> event) {
>>>> logger.info("Resumed: " +
>>>> event.getResource().getRequest().getRemoteAddr());
>>>> }
>>>>
>>>> public void onSuspend(AtmosphereResourceEvent<HttpServletRequest,
>>>> HttpServletResponse> event) {
>>>> logger.info("Suspended: " +
>>>> event.getResource().getRequest().getRemoteAddr());
>>>> }
>>>>
>>>> public void onThrowable(AtmosphereResourceEvent<HttpServletRequest,
>>>> HttpServletResponse> event) {
>>>> logger.info("Throwed: " +
>>>> event.getResource().getRequest().getRemoteAddr());
>>>> }
>>>> }
>>>
>>> First time I try to subscribe, the log is;
>>>
>>>> 63 [qtp701905307-21] INFO org.atmosphere.cpr.AtmosphereServlet -
>>>> started atmosphere framework: 0.7
>>>> 80 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>> Suspended: 0:0:0:0:0:0:0:1%0
>>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>> Connected:0:0:0:0:0:0:0:1%0
>>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>> Broadcaster:org.atmosphere.cpr.DefaultBroadcaster@1108628844
>>>> Name: /*
>>>> Scope: APPLICATION
>>>> BroasdcasterCache
>>>> org.atmosphere.cpr.BroadcasterConfig$DefaultBroadcasterCache@44f44758
>>>> AtmosphereResource: 1
>>>
>>>
>>> Finally the container I've tried with are jetty 6 and 8.0.M2, result
>>> is same;
>>>
>>>> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response)
>>>> { alert("Response Received:" + response.responseBody); }, {} );
>>>
>>>
>>> My callback is not executed, the interesting part is, callback
>>> function is executed for all clients when I shutdown the server.
>>
>> That strange as it means the bytes are buffered in the socket and
>> flushed when socket gets closed.
>>
>>>
>>> My question is with AtmosphereHandler, when a broadcast happens
>>> onStateChange is executed and we push the message with the response
>>> writer right?
>>
>> Yes, onStateChange gets called.
>>
>> With Meteor, is just broadcasting the message enough?
>>
>> It should as under the hood it does the same. The Meteor is really a
>> wrapper around an existing AtmosphereHandler.
>>
>> Let me try to reproduce the issue locally.
>>
>> A+
>>
>> -- Jeanfrancois
>>
>>
>>>
>>> Thanks for your time Jeanfrancois,
>>>
>>> Cagatay
>>>
>>> On Mar 25, 2011, at 3:07 PM, jfarcand wrote:
>>>
>>>> Salut,
>>>>
>>>> On 11-03-25 4:45 AM, Cagatay Civici wrote:
>>>>> Hi,
>>>>>
>>>>> I'm trying to use meteorservlet and jquery plugin together and can't
>>>>> figure out what's wrong;
>>>>>
>>>>> Test case is simple, whenever a client connects,
>>>>>
>>>>> Servlet
>>>>> public class ListServlet extends HttpServlet {
>>>>>
>>>>> @Override
>>>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>>>> resp) throws ServletException, IOException {
>>>>> Meteor meteor = Meteor.build(req);
>>>>>
>>>>> req.getSession().setAttribute("meteor", meteor);
>>>>>
>>>>> meteor.suspend(-1);
>>>>>
>>>>> meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>>>> }
>>>>> }
>>>>>
>>>>> Mapping
>>>>> <servlet>
>>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>>> <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>>>>> <init-param>
>>>>> <param-name>org.atmosphere.servlet</param-name>
>>>>> <param-value>org.primefaces.examples.ListServlet</param-value>
>>>>> </init-param>
>>>>> </servlet>
>>>>> <servlet-mapping>
>>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>>> <url-pattern>/meteor/*</url-pattern>
>>>>> </servlet-mapping>
>>>>>
>>>>> And a client side code;
>>>>>
>>>>> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>>>>> function(response) { alert("Response Received:" +
>>>>> response.responseBody); },
>>>>> { });
>>>>> }
>>>>>
>>>>> I was expecting to get broadcasted message "Connected {user-agent}"
>>>>> on my callback as response.responseBody but nothing happens although
>>>>> doGet is executed as I've checked.
>>>>
>>>> Can you print the broadcaster instance? The Atmosphere resource
>>>> number is probably 0 ... My guess is the connection is not yet
>>>> suspended. Which container are you using?
>>>>
>>>> A+
>>>>
>>>> - Jeanfrancois
>>>>
>>>>
>>>>>
>>>>> Cagatay
>>>
>>>
>>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Jeanfrancois Arcand-4
Salut,

you need to resume when an event occurs to support long polling. Add the
following:

>                 @Override
>                 public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
>                     event.getResource().getRequest().setAttribute(AtmosphereServlet.RESUME_ON_BROADCAST, "true");
>                 }

That will resume the connection after the first broadcast. That should
fix the issue.

A+

-- Jeanfrancois

On 11-03-25 4:31 PM, Cagatay Civici wrote:

> Hi,
>
> Here's an update, I thought default transport was websocket according to;
>
> http://java.dzone.com/articles/using-atmospheres-jquery-plug
>
> But jquery plugins uses long-polling as default, after changing to websocket my callback started to get executed.
>
>> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response) { alert("Response Received:" + response.responseBody); }, {transport: 'websocket'} );
>
> I still have a problem with long-polling though, changed my code to handle long-polling like below and callback is not executed.
>
>> public class CounterServlet extends HttpServlet implements AtmosphereResourceEventListener {
>>
>>      public final static Logger logger = LoggerFactory.getLogger(CounterServlet.class);
>>
>>      @Override
>>      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
>>          Meteor meteor = Meteor.build(req);
>>
>>          req.getSession().setAttribute("meteor", meteor);
>>
>>          meteor.addListener(this);
>>
>>          String transport = req.getHeader("X-Atmosphere-Transport");
>>
>>          meteor.suspend(-1, !(transport != null&&  transport.equalsIgnoreCase("long-polling")));
>>
>>          meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>      }
>>
>>      public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Broadcasting " + event.getMessage());
>>
>>          // If transport is long-polling, resume the connection when event is received.
>>          String transport = event.getResource().getRequest().getHeader("X-Atmosphere-Transport");
>>          if (transport != null&&  transport.equalsIgnoreCase("long-polling")) {
>>              Meteor meteor = Meteor.lookup(event.getResource().getRequest());
>>
>>              meteor.removeListener(this);
>>              meteor.resume();
>>          }
>>      }
>>
>>      public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Disconnected:" + event.getResource().getRequest().getHeader("user-agent"));
>>      }
>>
>>      public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Resumed: " + event.getResource().getRequest().getHeader("user-agent"));
>>      }
>>
>>      public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Suspended: " + event.getResource().getRequest().getHeader("user-agent"));
>>      }
>>
>>      public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>          logger.info("Throwed: " + event.getResource().getRequest().getHeader("user-agent"));
>>      }
>> }
>
> I'll prepare a simple war and send you Jeanfrancois, thanks very much again.
>
> Cagatay
>
> On Mar 25, 2011, at 10:03 PM, jfarcand wrote:
>
>> Salut,
>>
>> the following works for me when I use AHC
>>
>>>     public static class Meteor1 extends HttpServlet {
>>>         @Override
>>>         public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
>>>             final Meteor m = Meteor.build(req);
>>>             req.getSession().setAttribute("meteor", m);
>>>             m.suspend(-1);
>>>
>>>             m.broadcast("resume");
>>>             m.addListener(new AtmosphereResourceEventListener(){
>>>
>>>                 @Override
>>>                 public void onSuspend(final AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event){
>>>                 }
>>>
>>>                 @Override
>>>                 public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>>                 }
>>>
>>>                 @Override
>>>                 public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>>                 }
>>>
>>>                 @Override
>>>                 public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>>                 }
>>>
>>>                 @Override
>>>                 public void onThrowable(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse>  event) {
>>>
>>>                 }
>>>             });
>>>
>>>             if (servletLatch != null) {
>>>                 servletLatch.countDown();
>>>             }
>>>         }
>>>     }
>>
>> Can you send me your war so I can take a look?
>>
>> Thanks!
>>
>> -- Jeanfracnois
>>
>>
>> On 11-03-25 3:53 PM, jfarcand wrote:
>>> Salut,
>>>
>>> On 11-03-25 3:37 PM, Cagatay Civici wrote:
>>>> Hi JF,
>>>>
>>>> I'm still trying to warmup, it has been quite some time since I've
>>>> last worked with Atmosphere.
>>>>
>>>> I've added a AtmosphereResourceEventListener to see what's going on
>>>> and suspend/broadcast part seems to be working fine;
>>>>
>>>>> public class CounterServlet extends HttpServlet implements
>>>>> AtmosphereResourceEventListener {
>>>>>
>>>>> public final static Logger logger =
>>>>> LoggerFactory.getLogger(CounterServlet.class);
>>>>>
>>>>> @Override
>>>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>>>> resp) throws ServletException, IOException {
>>>>> Meteor meteor = Meteor.build(req);
>>>>>
>>>>> req.getSession().setAttribute("meteor", meteor);
>>>>>
>>>>> meteor.addListener(this);
>>>>>
>>>>> meteor.suspend(-1);
>>>>>
>>>>> meteor.broadcast("Connected:" + req.getRemoteAddr());
>>>>>
>>>>> logger.info("Connected:" + req.getRemoteAddr());
>>>>> logger.info("Broadcaster:" + meteor.getBroadcaster());
>>>>> logger.info("Resource:" + meteor.getAtmosphereResource());
>>>>> }
>>>>>
>>>>> public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest,
>>>>> HttpServletResponse>  event) {
>>>>> logger.info("Broadcasting " + event.getMessage());
>>>>> }
>>>>>
>>>>> public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest,
>>>>> HttpServletResponse>  event) {
>>>>> logger.info("Disconnected:" +
>>>>> event.getResource().getRequest().getRemoteAddr());
>>>>> }
>>>>>
>>>>> public void onResume(AtmosphereResourceEvent<HttpServletRequest,
>>>>> HttpServletResponse>  event) {
>>>>> logger.info("Resumed: " +
>>>>> event.getResource().getRequest().getRemoteAddr());
>>>>> }
>>>>>
>>>>> public void onSuspend(AtmosphereResourceEvent<HttpServletRequest,
>>>>> HttpServletResponse>  event) {
>>>>> logger.info("Suspended: " +
>>>>> event.getResource().getRequest().getRemoteAddr());
>>>>> }
>>>>>
>>>>> public void onThrowable(AtmosphereResourceEvent<HttpServletRequest,
>>>>> HttpServletResponse>  event) {
>>>>> logger.info("Throwed: " +
>>>>> event.getResource().getRequest().getRemoteAddr());
>>>>> }
>>>>> }
>>>>
>>>> First time I try to subscribe, the log is;
>>>>
>>>>> 63 [qtp701905307-21] INFO org.atmosphere.cpr.AtmosphereServlet -
>>>>> started atmosphere framework: 0.7
>>>>> 80 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>>> Suspended: 0:0:0:0:0:0:0:1%0
>>>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>>> Connected:0:0:0:0:0:0:0:1%0
>>>>> 83 [qtp701905307-21] INFO org.primefaces.examples.CounterServlet -
>>>>> Broadcaster:org.atmosphere.cpr.DefaultBroadcaster@1108628844
>>>>> Name: /*
>>>>> Scope: APPLICATION
>>>>> BroasdcasterCache
>>>>> org.atmosphere.cpr.BroadcasterConfig$DefaultBroadcasterCache@44f44758
>>>>> AtmosphereResource: 1
>>>>
>>>>
>>>> Finally the container I've tried with are jetty 6 and 8.0.M2, result
>>>> is same;
>>>>
>>>>> $.atmosphere.subscribe('/prime-showcase/meteor/', function(response)
>>>>> { alert("Response Received:" + response.responseBody); }, {} );
>>>>
>>>>
>>>> My callback is not executed, the interesting part is, callback
>>>> function is executed for all clients when I shutdown the server.
>>>
>>> That strange as it means the bytes are buffered in the socket and
>>> flushed when socket gets closed.
>>>
>>>>
>>>> My question is with AtmosphereHandler, when a broadcast happens
>>>> onStateChange is executed and we push the message with the response
>>>> writer right?
>>>
>>> Yes, onStateChange gets called.
>>>
>>> With Meteor, is just broadcasting the message enough?
>>>
>>> It should as under the hood it does the same. The Meteor is really a
>>> wrapper around an existing AtmosphereHandler.
>>>
>>> Let me try to reproduce the issue locally.
>>>
>>> A+
>>>
>>> -- Jeanfrancois
>>>
>>>
>>>>
>>>> Thanks for your time Jeanfrancois,
>>>>
>>>> Cagatay
>>>>
>>>> On Mar 25, 2011, at 3:07 PM, jfarcand wrote:
>>>>
>>>>> Salut,
>>>>>
>>>>> On 11-03-25 4:45 AM, Cagatay Civici wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm trying to use meteorservlet and jquery plugin together and can't
>>>>>> figure out what's wrong;
>>>>>>
>>>>>> Test case is simple, whenever a client connects,
>>>>>>
>>>>>> Servlet
>>>>>> public class ListServlet extends HttpServlet {
>>>>>>
>>>>>> @Override
>>>>>> protected void doGet(HttpServletRequest req, HttpServletResponse
>>>>>> resp) throws ServletException, IOException {
>>>>>> Meteor meteor = Meteor.build(req);
>>>>>>
>>>>>> req.getSession().setAttribute("meteor", meteor);
>>>>>>
>>>>>> meteor.suspend(-1);
>>>>>>
>>>>>> meteor.broadcast("Connected:" + req.getHeader("user-agent"));
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> Mapping
>>>>>> <servlet>
>>>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>>>> <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
>>>>>> <init-param>
>>>>>> <param-name>org.atmosphere.servlet</param-name>
>>>>>> <param-value>org.primefaces.examples.ListServlet</param-value>
>>>>>> </init-param>
>>>>>> </servlet>
>>>>>> <servlet-mapping>
>>>>>> <servlet-name>Meteor Servlet</servlet-name>
>>>>>> <url-pattern>/meteor/*</url-pattern>
>>>>>> </servlet-mapping>
>>>>>>
>>>>>> And a client side code;
>>>>>>
>>>>>> function connect() { $.atmosphere.subscribe('/prime-showcase/meteor/',
>>>>>> function(response) { alert("Response Received:" +
>>>>>> response.responseBody); },
>>>>>> { });
>>>>>> }
>>>>>>
>>>>>> I was expecting to get broadcasted message "Connected {user-agent}"
>>>>>> on my callback as response.responseBody but nothing happens although
>>>>>> doGet is executed as I've checked.
>>>>>
>>>>> Can you print the broadcaster instance? The Atmosphere resource
>>>>> number is probably 0 ... My guess is the connection is not yet
>>>>> suspended. Which container are you using?
>>>>>
>>>>> A+
>>>>>
>>>>> - Jeanfrancois
>>>>>
>>>>>
>>>>>>
>>>>>> Cagatay
>>>>
>>>>
>>>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

jfarcand
Administrator
Salut, quick update

FYI the test you sent me (Thanks!!!) works perfectly well with Tomcat 6, e.g the broadcast is delivered properly. I will now look at Jetty.

Thanks!

-- Jeanfrancois
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Jeanfrancois Arcand-4
Salut,

it works well with Jetty 8.0.0.M2 as well....are you running mvn
jetty:run by any chance? Me it it fail with

> [ERROR] urls[29] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-websocket/8.0.0.M2/jetty-websocket-8.0.0.M2.jar
> [ERROR] urls[30] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-server/8.0.0.M2/jetty-server-8.0.0.M2.jar
> [ERROR] urls[31] = file:/Users/jfarcand/.m2/repository/org/mortbay/jetty/servlet-api/3.0.20100224/servlet-api-3.0.20100224.jar
> [ERROR] urls[32] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-continuation/8.0.0.M2/jetty-continuation-8.0.0.M2.jar
> [ERROR] urls[33] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-http/8.0.0.M2/jetty-http-8.0.0.M2.jar
> [ERROR] urls[34] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-io/8.0.0.M2/jetty-io-8.0.0.M2.jar
> [ERROR] Number of foreign imports: 1
> [ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
> [ERROR]
> [ERROR] -----------------------------------------------------: javax.servlet.http.HttpServletRequest
> [ERROR] -> [Help 1]

but if I manually start Jetty 8 everything works as expected.

A+

-- Jeanfrancois

On 11-03-28 9:30 AM, jfarcand wrote:

> Salut, quick update
>
> FYI the test you sent me (Thanks!!!) works perfectly well with Tomcat 6, e.g
> the broadcast is delivered properly. I will now look at Jetty.
>
> Thanks!
>
> -- Jeanfrancois
>
> --
> View this message in context: http://atmosphere-users-mailling-list.2493822.n2.nabble.com/Meteor-and-jQuery-Plugin-tp6206958p6214957.html
> Sent from the Atmosphere users mailling list mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

Cagatay Civici
Hi JF,

Yes I was using mvn jetty plugin, will test with tomcat6 and standalone jetty.

Thanks very much for your time again.

Cagatay

On Mar 28, 2011, at 4:47 PM, jfarcand wrote:

> Salut,
>
> it works well with Jetty 8.0.0.M2 as well....are you running mvn jetty:run by any chance? Me it it fail with
>
>> [ERROR] urls[29] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-websocket/8.0.0.M2/jetty-websocket-8.0.0.M2.jar
>> [ERROR] urls[30] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-server/8.0.0.M2/jetty-server-8.0.0.M2.jar
>> [ERROR] urls[31] = file:/Users/jfarcand/.m2/repository/org/mortbay/jetty/servlet-api/3.0.20100224/servlet-api-3.0.20100224.jar
>> [ERROR] urls[32] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-continuation/8.0.0.M2/jetty-continuation-8.0.0.M2.jar
>> [ERROR] urls[33] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-http/8.0.0.M2/jetty-http-8.0.0.M2.jar
>> [ERROR] urls[34] = file:/Users/jfarcand/.m2/repository/org/eclipse/jetty/jetty-io/8.0.0.M2/jetty-io-8.0.0.M2.jar
>> [ERROR] Number of foreign imports: 1
>> [ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
>> [ERROR]
>> [ERROR] -----------------------------------------------------: javax.servlet.http.HttpServletRequest
>> [ERROR] -> [Help 1]
>
> but if I manually start Jetty 8 everything works as expected.
>
> A+
>
> -- Jeanfrancois
>
> On 11-03-28 9:30 AM, jfarcand wrote:
>> Salut, quick update
>>
>> FYI the test you sent me (Thanks!!!) works perfectly well with Tomcat 6, e.g
>> the broadcast is delivered properly. I will now look at Jetty.
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>> --
>> View this message in context: http://atmosphere-users-mailling-list.2493822.n2.nabble.com/Meteor-and-jQuery-Plugin-tp6206958p6214957.html
>> Sent from the Atmosphere users mailling list mailing list archive at Nabble.com.
>>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

jandres
Hi,

I'm trying to use Meteorservlet and jquery plugin and I have the same problems as Cagatay. My suspend/broadcast part seems to work, but my callback is not executed. This callback function is executed when I shutdown the server.

I’m using Tomcat 7.0.19, and the example with the meteorservlet chat and prototype is working fine.

Have you find a solution for this?

Thank you!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

alnikolov
In reply to this post by Cagatay Civici
I had this issue when I first used jQuery plug-in.
Did you add the JavascriptClientFilter to your servlet init-params or in the case of meter to your meteor initialization?
I mean your code should look something like this:
public class ListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<BroadcastFilter> list = new LinkedList<BroadcastFilter>();
        list.add(new JavascriptClientFilter());
        Meteor meteor = Meteor.build(req, list, null);

        req.getSession().setAttribute("meteor", meteor);

        meteor.suspend(-1);

        meteor.broadcast("Connected:" + req.getHeader("user-agent"));
    }
}

Without the JavascriptClientFilter filter the required <script> wrapper will not be added to your broadcast and the plug-in will not recognize the message. It uses the script tags as markers for the beginning and the end of the message when using XMLHTTPRequest object, and in the case of Opera and long polling it uses hidden iframe - again the script is needed in order to call the call-back function.
When the scrip tags are missing the plug-in will just accumulate the messages without calling your call-back.

You receive the messages when you shut-down the server because the plug-in is releasing all the accumulated data when the line goes down.

Hope this helps.
Aleksandar Nikolov

P.S. I am glad to see you working with atmosphere again :) Does it mean we will soon see an upgrade to the push component in PrimeFaces?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meteor and jQuery Plugin

jandres
Thank you very much!

Now it’s working, but i had to remove others filters:

// list.add(new XSSHtmlFilter());
//         list.add(new JsonpFilter());
       
list.add(new org.atmosphere.client.JavascriptClientFilter());


And I’m waiting for an upgrade to the push component in Primefaces too
Loading...