• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JID类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.appengine.api.xmpp.JID的典型用法代码示例。如果您正苦于以下问题:Java JID类的具体用法?Java JID怎么用?Java JID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JID类属于com.google.appengine.api.xmpp包,在下文中一共展示了JID类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendXmppMessage

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public static boolean sendXmppMessage(String p_jabberId, ChatMessage p_chatMessage)
{
  boolean messageSent = false;
  if( p_jabberId != null )
  {
    JID jid = new JID(p_jabberId);
    String msgBody = "[" + p_chatMessage.getFromPseudo() + "] " + p_chatMessage.getText();
    Message msg = new MessageBuilder()
                      .withRecipientJids(jid)
                      .withBody(msgBody)
                      .build();
            
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    SendResponse status = xmpp.sendMessage(msg);
    messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
  }
  return messageSent;
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:19,代码来源:XMPPMessageServlet.java


示例2: doPost

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws IOException {
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    
    Message message = xmpp.parseMessage(req);

    JID fromJid = message.getFromJid();
    String body = message.getBody();
    JID toJid = new JID("[email protected]/arlearn");
    //XMPPService xmppService = XMPPServiceFactory.getXMPPService();
    xmpp.sendPresence( toJid, PresenceType.AVAILABLE, PresenceShow.NONE, "Dit is mijn status");
    
    Message msg = new MessageBuilder()
    .asXml(true)
    .withRecipientJids( toJid)
    .withBody("Dit is een bericht voor stefaan op android")
    .build();
    
    xmpp.sendMessage(msg);
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:21,代码来源:XMPPReceiverServlet.java


示例3: testXmppSendMessageAndReceiveDefaultJid

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
@Test
public void testXmppSendMessageAndReceiveDefaultJid() {
    assumeEnvironment(Environment.APPSPOT);

    JID fromJID = new JID(appId + "@" + xmppServer);
    // We're sending messages to ourselves, so toJID and fromJID are the same.
    @SuppressWarnings("UnnecessaryLocalVariable")
    JID toJID = fromJID;

    MessageBuilder builder = new MessageBuilder();
    builder.withMessageType(MessageType.valueOf("CHAT"));
    builder.withFromJid(fromJID);
    builder.withRecipientJids(toJID);
    String testBody = TEST_BODY + System.currentTimeMillis();
    builder.withBody(testBody);
    builder.asXml(false);
    Message msg = builder.build();

    SendResponse response = xmppService.sendMessage(msg);
    assertNotNull("expected a response", response);
    assertEquals(1, response.getStatusMap().size());
    assertEquals(SendResponse.Status.SUCCESS, response.getStatusMap().get(toJID));

    verifyChatReceivedWithBody(testBody);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:26,代码来源:SimpleXmppTest.java


示例4: processMessage

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public void processMessage(Message message, HttpServletResponse res) throws IOException {
  JID fromId = message.getFromJid();
  Presence presence = xmppService.getPresence(fromId);
  String presenceString = presence.isAvailable() ? "" : "not ";
  SendResponse response = xmppService.sendMessage(
      new MessageBuilder().
      withBody(message.getBody() + " (you are " + presenceString + "available)").
      withRecipientJids(fromId).
      build());

  for (Map.Entry<JID, SendResponse.Status> entry :
      response.getStatusMap().entrySet()) {
    res.getWriter().println(entry.getKey() + "," + entry.getValue() + "<br>");
  }

  res.getWriter().println("processed");
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:18,代码来源:HelloXmpp.java


示例5: doPost

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
	XMPPService xmpp = XMPPServiceFactory.getXMPPService();
	Message msg = xmpp.parseMessage(req);

	JID fromJid = msg.getFromJid();
	String body = msg.getBody();

	// Unsubscribe, if requested
	if (body.startsWith("STOP")) {
		MultichannelChatManager.removeSub(fromJid.getId());
	} else {
		// If they aren't subscribed, subscribe them
		if (!MultichannelChatManager.isSubscribed(fromJid.getId())) {
			MultichannelChatManager.addSub(fromJid.getId());
		}
		MultichannelChatManager.sendMessage(body, "xmpp");
	}
}
 
开发者ID:kwhinnery,项目名称:gae-chat,代码行数:19,代码来源:XMPPReceiverServlet.java


示例6: isPresent

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public static boolean isPresent(String p_jabberId)
{
  if( p_jabberId == null )
  {
    return false;
  }
  XMPPService xmpp = XMPPServiceFactory.getXMPPService();
  return xmpp.getPresence( new JID( p_jabberId ) ).isAvailable();
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:10,代码来源:XMPPMessageServlet.java


示例7: sendPresence

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public static void sendPresence(JID p_jid)
{
  PresenceRoom room = ChannelManager.getRoom( 0 );
  PresenceType pt = PresenceType.AVAILABLE;
  int count = room.countPseudo();
  if( count <= 1 )
  {
    pt = PresenceType.UNAVAILABLE;
  }
  XMPPService xmppService = XMPPServiceFactory.getXMPPService();
  xmppService.sendPresence( p_jid, pt, PresenceShow.NONE, "" + count + " joueurs" );
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:13,代码来源:XMPPProbeServlet.java


示例8: broadcast

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
/**
 * broadcast PresenceRoom over all user connected to this room.
 * @param p_room
 */
protected static void broadcast(PresenceRoom p_room)
{
  AppRoot.logger.fine( "ChannelManager.broadcast room "+ p_room.getGameId() );
  
  String response = Serializer.toClient( p_room );

  if( response != null )
  {
    for( Presence presence : p_room )
    {
      if( presence.getClientType() == ClientType.XMPP )
      {
        if( presence.getJabberId() != null )
        {
          // send presence to xmpp clients
          XMPPProbeServlet.sendPresence( new JID( presence.getJabberId() ) );
        }
        else
        {
          AppRoot.logger.severe( "Send a PresenceRoom, but his XMPP presence have a JabberId null !" );
        }
      }
      else
      {
        // send presence to web client
        try
        {
          AppRoot.logger.finer( "ChannelManager.sendMessage "+ presence.getChannelId() );
          s_channelService.sendMessage( new ChannelMessage( presence.getChannelId(), response ) );
        } catch( Exception e )
        {
          AppRoot.logger.severe( e.getMessage() );
        }
      }
    }
  }
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:42,代码来源:ChannelManager.java


示例9: sendMessage

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
protected void sendMessage(JID[] recipients, String body) {
	Message message = new MessageBuilder()
	.withRecipientJids(recipients)
	.withMessageType(MessageType.NORMAL)
	.withBody(body)
	.build();

	xmppService.sendMessage(message);
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:10,代码来源:AbstractStrategy.java


示例10: doGet

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws IOException {
  Message message =new MessageBuilder()
      .withMessageType(MessageType.CHAT)
      .withFromJid(new JID(req.getParameter("from")))
      .withRecipientJids(new JID(req.getParameter("to")))
      .withBody(req.getParameter("body"))
      .build();
  processMessage(message, res);
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:11,代码来源:HelloXmpp.java


示例11: sendMessage

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public static void sendMessage(String body, String source) {
	Iterator<String> it = subs.iterator();
	while (it.hasNext()) {
		String sub = it.next();
		String messageBody = source + ": " + body;

		// We assume an at symbol is an XMPP client...
		if (sub.indexOf("@") >= 0) {
			JID jid = new JID(sub);
			Message msg = new MessageBuilder().withRecipientJids(jid).withBody(messageBody).build();
			XMPPService xmpp = XMPPServiceFactory.getXMPPService();
			xmpp.sendMessage(msg);
		}
		
		// If it starts with a "+" it's an SMS number...
		else if (sub.startsWith("+")) {
			TwilioRestClient client = new TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN");

			Map<String, String> params = new HashMap<String, String>();
			params.put("Body", messageBody);
			params.put("To", sub);
			params.put("From", "+16122948105");

			SmsFactory messageFactory = client.getAccount().getSmsFactory();

			try {
				Sms message = messageFactory.create(params);
				System.out.println(message.getSid());
			} catch (TwilioRestException e) {
				e.printStackTrace();
			}
		}

		// Otherwise, it's a browser-based client
		else {
			ChannelService channelService = ChannelServiceFactory.getChannelService();
			channelService.sendMessage(new ChannelMessage(sub,messageBody));
		}
	}
}
 
开发者ID:kwhinnery,项目名称:gae-chat,代码行数:41,代码来源:MultichannelChatManager.java


示例12: sendTimelineUpdates

import com.google.appengine.api.xmpp.JID; //导入依赖的package包/类
public static void sendTimelineUpdates(String gtalkId) throws TwitterException {
	UserAccount userAccount = new UserAccount(gtalkId);
	if(userAccount!=null && userAccount.getIsTimelineActive()) {
		UserTwitterTimeline userTT = new UserTwitterTimeline(gtalkId);
		Long ttSinceId = userTT.getTwitterTimelineSinceId();
		Long dmSinceId = userTT.getTwitterDirectMessageSinceId();
		String accessToken = userAccount.getTwitterAccessToken(); 
		String accessTokenSecret = userAccount.getTwitterAccessTokenSecret();

		System.out.println("Starting routine task for user " + gtalkId + " ... ttSince " + ttSinceId + " dmSince " + dmSinceId);
		System.out.println("with accessToken " + accessToken + " and accessTokenSecret " + accessTokenSecret);
		if ((dmSinceId != null) && (ttSinceId != null) && (gtalkId != null) && (accessToken != null) && (accessTokenSecret != null)) {
			System.out.println("started");
			Twitter twitter = TwitterAPI.getInstanceFor(accessToken, accessTokenSecret);
			System.out.println("Twitter authentication is set for " + twitter.getScreenName() + ". ");

			ResponseList<Status> timeline = twitter.getHomeTimeline(new Paging(ttSinceId.longValue()));
			System.out.println("Timeline fetched for " + twitter.getScreenName() + " with sizes " + timeline.size());

			String fullMessageBody = "---";
			String fullMessageBodyHTML = "<p>---</p>";
			for (int i = timeline.size() - 1; i >= 0; i--) {
				System.out.println("Trying to get " + i + "th wall post.");
				Status status = (Status)timeline.get(i);
				System.out.println("Yes, we're in");
				if (!status.getUser().getScreenName().equals(twitter.getScreenName())) {
					String messageBody = "_*" + status.getUser().getScreenName() + ":*_ ";
					String messageBodyHTML = "<p><b><i>" + status.getUser().getScreenName() + ":</i></b> ";
					if (status.isRetweet()) {
						messageBody = messageBody + "_rt_ _" + status.getRetweetedStatus().getUser().getScreenName() + "_: " + status.getRetweetedStatus().getText();
						messageBodyHTML = messageBodyHTML + "<i>rt</i> <i>" + status.getRetweetedStatus().getUser().getScreenName() + "</i>: " + status.getRetweetedStatus().getText() + "</p>";
					} else {
						messageBody = messageBody + status.getText();
						messageBodyHTML = messageBodyHTML + status.getText() + "</p>";
					}

					fullMessageBody = fullMessageBody + "\n" + messageBody;
					fullMessageBodyHTML = fullMessageBodyHTML + messageBodyHTML;
				}
			}
			if (fullMessageBody != "---")
			{
				Message message = messageBuilder
						.withRecipientJids(new JID[] { 
								new JID(gtalkId) })
								.withMessageType(MessageType.CHAT)
								.withBody(fullMessageBody)
								.build();

				xmppService.sendMessage(message);
			}

			boolean isSinceIdsChanged = false;
			if (timeline.size() > 0) {
				ttSinceId = Long.valueOf(((Status)timeline.get(0)).getId());
				isSinceIdsChanged = true;
			}

			if (isSinceIdsChanged)
				new UserTwitterTimeline(gtalkId, ttSinceId, dmSinceId);
		}
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:64,代码来源:StreamCronjobServlet.java



注:本文中的com.google.appengine.api.xmpp.JID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataContainerNode类代码示例发布时间:2022-05-22
下一篇:
Java AlipayConfig类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap