Closed GoogleCodeExporter closed 9 years ago
I can add close(), but I don't see any documentation for the send() or
readyState features at
http://code.google.com/appengine/docs/java/channel/javascript.html
Particularly, I don't believe send() is supported through the Channel API,
messages from client to server must be implemented as regular XHR requests.
Even if this functionality is included in the JS source, if it's not supported
by the App Engine server, then there's no point in exposing it in the GWT
wrapper.
So I'll add close() in a change soon,
http://code.google.com/p/gwt-gae-channel/issues/detail?id=1 also mentions the
need to expose the onerror and onclose methods, which I can add as well.
Original comment by jasonhall@google.com
on 3 Feb 2011 at 4:13
I know that this is not documented. I just wanted to tell you that it exists
and it is working :)
I have allready tested the send method and it works perfectly.
Why else would there be a getChannelService().parseMessage(request) function?
If you want to try it out do the following:
1. Add a servlet mapping in your web.xml
<servlet>
<servlet-name>channelServlet</servlet-name>
<servlet-class>com.google.gwt.channel.server.ChannelServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>channelServlet</servlet-name>
<url-pattern>/_ah/channel/receive</url-pattern>
</servlet-mapping>
2. Create the class com.google.gwt.channel.server.ChannelServlet like this:
public class ChannelServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
ChannelMessage msg = getChannelService().parseMessage(req);
msg.getClientId(); // ClientId
msg.getMessage(); // Message
}
private static ChannelService getChannelService() {
return ChannelServiceFactory.getChannelService();
}
}
3. In your gwt code just do a socket.send("Hello World"); and the message gets
send.
Original comment by buchholz...@googlemail.com
on 3 Feb 2011 at 4:28
Wow, that's great, I didn't realize that actually worked. Still, I'd rather
keep the GWT wrapper limited to just methods that are documented. The Channel
API may stop supporting this at some point, or may change things about it in
breaking ways, and they may have decided not to document it in order to reserve
the right.
Still, thanks for pointing this out, let's hope they officially add this in a
future release.
If you feel comfortable using this functionality yourself, it should be
possible subclass the Channel class to add the send() method as a JSNI method.
When you get your channel from ChannelFactory you can call MyChannel my =
channel.cast(); to cast the standard Channel to your own MyChannel.
Original comment by jasonhall@google.com
on 3 Feb 2011 at 4:38
Original comment by jasonhall@google.com
on 3 Feb 2011 at 4:39
Thanks!
I already have my own implementation running but thank you for the subclassing
tip!
If you want to know where I found these things look at this gist:
https://gist.github.com/809830
which is the readable copy of the javascript code on the appengine dev server.
(http://127.0.0.1:8888/_ah/channel/jsapi or
http://talkgadget.google.com/talkgadget/channel.js for the production server)
On line 5556 is the send method.
On line 5566 is the close method.
On line 5496 is the ReadyState constant defined.
All other thing are also around at these lines.
Original comment by buchholz...@googlemail.com
on 3 Feb 2011 at 5:48
Just another note:
These APIs are currently in the dev version of the html5 websocket API
http://dev.w3.org/html5/websockets/
And the appengine channel is just an early implemention of it.
Original comment by buchholz...@googlemail.com
on 3 Feb 2011 at 7:41
The send method is *NOT* supported on the *PRODUCTION* server.
You can call it but it just returns false...
Original comment by buchholz...@googlemail.com
on 2 Mar 2011 at 6:03
Original issue reported on code.google.com by
buchholz...@googlemail.com
on 3 Feb 2011 at 4:04Attachments: