I'm trying to create a common chat room app in google app engine till now i'm able to create the token for the userid...i.e when user logs in with a name . a token is created for the name. which is being displayed in the text area
my problem is that after getting this token i'n not able to open the channel or use use the channel i'm stuck here form long time.
<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 is "+clientid);
$('#display').val(" tok id is "+data.token);
}
)
});<code></code>
});
</script>
This is my html(js or jquery) where i'm able to create the token by sending the clientid which is entered by the user and sending it to the servlet(chatroom.java)
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 is ="+token);
JSONObject job=new JSONObject();
job.put("token",token);
String jsondata=job.toString();
out.write(jsondata);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
this is my servlet where i'm able to create the token now my question is how to open this channel and use it to display(for now) connection established message .i need a little example for channel api working procedure .. waiting for the answers!!!