Hi All,
I have implemented sample chat application using ChannelAPI.
I have created the channel, and the I can see the channel got
connected in the firebug
I am passing the same channelkey to the sendMessage function.
But it is not sending the msg back to the client..
It says Skipping Message to unconnected channel
Here is the code I have written on the server side:
For creating the token:
String key = "tokenchat";
ChannelService channelService =
ChannelServiceFactory.getChannelService();
String token = channelService.createChannel(key);
Here is the code for sendMessage:
ChannelService channelService =
ChannelServiceFactory.getChannelService();
ChannelMessage lMessage= new
ChannelMessage(channelKey.trim(), "Test Message");
channelService.sendMessage(lMessage);
And here is my javascript code:
var connected = false;
sendMessage = function(path, opt_param) {
console.info('The channel key is ::'+channelKey);
//path='http://localhost:8888/channelMessage.do';
path += '?channelKey=' + channelKey;
if (opt_param) {
path += '&' + opt_param;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', path, true);
xhr.send();
};
onOpened = function() {
connected = true;
console.info("Inside open function");
};
onMessage = function(msg) {
alert('IN SOCKETs ONMESSAGE FUNCTION');
var data = $.parseJSON(msg.data);
console.debug("content: " + data.content);
};
onError = function() {
};
onClose = function() {
socket.close();
};
function channelopen(channeltoken)
{
console.info('channel token is ::'+channeltoken);
channel = new goog.appengine.Channel(channeltoken);
socket = channel.open();
socket.onopen = onOpened;
// socket.connect(channel);
socket.onmessage = onMessage;
socket.onerror = onError;
socket.onclose = onClose;
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.