package com.pushwish.server;
import java.io.IOException;
import java.util.logging.Logger;
import com.google.appengine.api.xmpp.JID;
import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.MessageBuilder;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
public class PushwishToGTalk {
private static final Logger log = Logger.getLogger(PushwishToGTalk.class.getName());
private JID tojid;
private XMPPService xmpp = XMPPServiceFactory.getXMPPService();
public PushwishToGTalk(String user) {
tojid = new JID(user);
}
public void push(String message) throws IOException {
if (xmpp.getPresence(tojid).isAvailable()) {
Message msg = new MessageBuilder().withRecipientJids(tojid)
.withBody("@Push-wish:" + message).build();
xmpp.sendMessage(msg);
} else {
// �� GTalk �ͻ��ˣ�������뱾������û����ƣ����ܽ��յ���Ϣ����������ǣ�push-wish@appspot.com
log.severe("Can't connect to user: " + tojid.getId() );
}
}
}