I found the problem and now pushing to the client works!! In the controller that creates the channel, I just need create the service and use the same id on the client. Whatever is returned by the create channel method is not the id that I need to use to send the message.
So this: > ChannelService channelService = > ChannelServiceFactory.getChannelService(); > > String channelId = channelService.createChannel("coupoz"); > > return new ChannelModel(channelId); becomes: ChannelService channelService = ChannelServiceFactory.getChannelService(); channelService.createChannel("coupoz"); return OK_RESPONSE; On the client, I just change: > var channel = new goog.appengine.Channel(channelId); to be: var channel = new goog.appengine.Channel("coupoz"); The push then works great, which is really all I needed, but I am interested in how to receive though. On Nov 24, 8:52 pm, Scott <shathaw...@gmail.com> wrote: > I am trying to use the Channel API in the 1.4.0 preview, but I am not > using GWT. Here is what I have done so far: > > 1. Using the Spring framework I have a controller that listens for a > channel create request form a client to create a new channel. The > controller creates the channel using the following code: > > ChannelService channelService = > ChannelServiceFactory.getChannelService(); > > String channelId = channelService.createChannel("coupoz"); > > return new ChannelModel(channelId); > > 2. The client, which imports the "_ah/channel/jsapi" script, then > creates a channel and opens a socket using the channel id returned by > the controller. Here is the client code: > > var channel = new goog.appengine.Channel(channelId); > var socket = channel.open(); > socket.onopen = function() {} > socket.onmessage = function(evt) { > var o = JSON.parse(evt.data); > alert(o); > } > > 3. I then have a button that I can push from the client that calls > another controller that sends a message to the client via the channel. > I am sending back the channel id in the call from the client. Here is > the code: > > ChannelService channelService = > ChannelServiceFactory.getChannelService(); > channelService.sendMessage(new > ChannelMessage(channelId,"test")); > > This seems bassackwards but when I tried just sending from the client > using socket.send and got the error below. Plus I have no idea to > listen for the send on the server side. > > WARNING: /_ah/channel/dev > com.google.appengine.api.channel.dev.LocalChannelFailureException: > Channel for application key null not found. > > When I try pushing to the client I get the following error: > com.google.appengine.api.channel.ChannelFailureException: An > unexpected error occurred. > . > . > . > Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: > ApplicationError: 2: > at > com.google.appengine.api.channel.dev.LocalChannelService.sendChannelMessage > (LocalChannelService.java: > 91) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > . > . > . > > Any tips or suggestions? > > Thanks! -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.