Package com.pushwish.server

Source Code of com.pushwish.server.PushwishToGTalk

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() );
    }
  }
}
TOP

Related Classes of com.pushwish.server.PushwishToGTalk

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.