java - How to get a response message from opening an App Engine Channel? -


i'm trying create typical chat room app in google app engine. far, when user logs in, i'm able create token them, being displayed in chat area.

my problem after getting token i'm not able open or use channel.

this javascript code below, i'm able create token sending user-entered clientid , sending servlet (chatroom.java):

 <script type="text/javascript">  $(document).ready(function(){       alert("doc");       $("#field1").hide();       $(".button").click(function(){          $("#field2").hide();          $("#field1").fadein(2500);          var clientid = $("#textbox2").val();          var form=$('#form1');           $.get(form.attr('action'),$(form1).serialize(),function(data,status){               alert(status);                     $('#display').val(" client id "+clientid);              $('#display').val(" tok id "+data.token);         });      });  });  </script> 

this servlet code below, i'm able create token:

package com.example.chatroom;  import java.io.ioexception; import java.io.printwriter;  import javax.servlet.http.*;  import com.google.appengine.api.channel.channelmessage; import com.google.appengine.api.channel.channelservice; import com.google.appengine.api.channel.channelservicefactory; import com.google.appengine.labs.repackaged.org.json.jsonobject;  @suppresswarnings("serial") public class chatroomservlet extends httpservlet {     public void doget(httpservletrequest request, httpservletresponse response)     throws ioexception {          response.setcontenttype("application/json");         printwriter out = response.getwriter();         try         {             string clientid = request.getparameter("clientid");             channelservice channelservice = channelservicefactory.getchannelservice();              string token = channelservice.createchannel(clientid);              system.out.println("token ="+token);              jsonobject job=new jsonobject();             job.put("token",token);              string jsondata=job.tostring();              out.write(jsondata);         }         catch(exception e)         {             e.printstacktrace();         }     } } 

how open channel , use display "connection established" message? need little example working channel api.

use function onopened() in javascript print client connected.

function onopened()  {  // event handler when connection has established.                      } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -