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

Java Message类代码示例

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

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



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

示例1: doPost

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

  // Split the XMPP address (e.g., [email protected])
  // from the resource (e.g., gmail.CD6EBC4A)
  String jid = message.getFromJid().getId();
  String pseudo = FmgDataStore.getPseudoFromJid( jid );
  String body = message.getBody();
  ChatMessage chatMessage = new ChatMessage( 0, pseudo, body );

  PresenceRoom room = ChannelManager.getRoom( 0 );
  Presence presence = room.getPresence( pseudo, 0 );
  if( presence == null )
  {
    // presence of the sender wasn't found in room...
    presence = new Presence( pseudo, 0, 0 );
    presence.setJabberId( jid );
    ChannelManager.connect( presence );
  }

  ChannelManager.broadcast( room, chatMessage );
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:26,代码来源:XMPPMessageServlet.java


示例2: sendXmppMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例3: doPost

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例4: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	replyToMessage(message, "You can order me:\n" +
			"_*/h*_ to show this help.\n" +
			"_*/on*_ to receive timeline updates\n" +
			"_*/off*_ to _not_ receive timeline updates\n" +
			"_*/t*_ to send a tweet.\n"+
			"_*/r*_ _*user*_ to send a tweet in reply to a user's _last_ tweet.\n"+
			"_*/q*_ _*category*_ to send quotes.\n\tavailable categories at http://j.mp/fbSRSr\n"+
			"_*/rt*_ _*user*_ to retweet a user's _last_ tweet.\n" +
			"_*/fav*_ _*user*_ to mark a user's _last_ tweet as _favorite_.\n" +
			"_*/d*_ _*user*_ to send direct message.\n" +
			"_*/f*_ _*user*_ to follow someone.\n" +
			"_*/u*_ _*user*_ to unfollow someone.\n" +
			"_*/i*_ to show incoming friendship requests.\n");
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:17,代码来源:HelpStrategy.java


示例5: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	try {
		Twitter twitter = TwitterAPI.getInstanceFor(userAccount);

		IDs ids;
		ids = twitter.getIncomingFriendships(-1);
		long[] idsArr=ids.getIDs();
		if(idsArr.length!=0){
			String msgBody="Your pending follow requests are:\n";
			for(long id : idsArr){
				User user=twitter.showUser(id);
				msgBody+="_"+user.getName()+"_"+" a.k.a _*"+user.getScreenName()+"*_\n";
			}
			replyToMessage(message,msgBody);
		} else {
			replyToMessage(message,"There are no pending requests.");
		}
	} catch (TwitterException e) {
		ExceptionPrinter.print(System.err, e, "Boss, I couldn't get incoming friendships for "+userAccount.getGtalkId());
		replyToMessage(message, "I couldn't get your incoming friendships.");
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:24,代码来源:IncomingFriendshipStrategy.java


示例6: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String followeeScreenName = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);
	try {
		if(!twitter.existsFriendship(twitter.getScreenName(), followeeScreenName)){
			twitter.createFriendship(followeeScreenName);
			replyToMessage(message, "You start following _*"+followeeScreenName+"*_.");	
		} else {
			replyToMessage(message, "You are already following _*"+followeeScreenName+"*_.");
		}
	} catch (TwitterException e) {
		/**
		 *  If existsFriendship throws an exception, 
		 *  we know that followee is a protected non-friend.
		 */
		try {
			twitter.createFriendship(followeeScreenName);
			replyToMessage(message, "You send a request to follow _*"+followeeScreenName+"*_.");
		} catch (TwitterException e1) {
			ExceptionPrinter.print(System.err, e1, "Boss, I couldn't send follow request from "+userAccount.getGtalkId()+" to "+followeeScreenName);
			replyToMessage(message, "I couldn't send your follow request.");	
		}		
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:27,代码来源:FollowStrategy.java


示例7: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String unfolloweeScreenName = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);
	try {
		if(!twitter.existsFriendship(twitter.getScreenName(), unfolloweeScreenName)){
			replyToMessage(message, "You are already _not_ following _*"+unfolloweeScreenName+"*_.");
		} else {
			twitter.destroyFriendship(unfolloweeScreenName);
			replyToMessage(message, "You stop following _*"+unfolloweeScreenName+"*_.");
		}
	} catch(TwitterException e) {
		/**
		 *  If existsFriendship throws an exception, 
		 *  we know that unfollowee is a protected non-friend.
		 */
		replyToMessage(message, "You are already _not_ following _*"+unfolloweeScreenName+"*_.");
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:21,代码来源:UnfollowStrategy.java


示例8: testXmppSendMessageAndReceiveDefaultJid

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例9: processMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例10: doPost

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例11: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String retweetedScreenName = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);

	try {
		twitter.retweetStatus(twitter.getUserTimeline(retweetedScreenName).get(0).getId());
		replyToMessage(message, "You retweeted _*"+retweetedScreenName+"*_ last status update.");
	} catch (TwitterException e) {
		ExceptionPrinter.print(System.err, e, "Boss, I couldn't retweet "+retweetedScreenName+"'s tweet for "+userAccount.getGtalkId());
		replyToMessage(message, "I couldn't retweeted _*"+retweetedScreenName+"*_ last status update.");
	}
	
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:16,代码来源:RetweetStrategy.java


示例12: replyToMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
protected void replyToMessage(Message message, String body) {
	Message reply = new MessageBuilder()
	.withRecipientJids(message.getFromJid())
	.withMessageType(MessageType.CHAT)
	.withBody(body)
	.build();
	xmppService.sendMessage(reply);
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:9,代码来源:AbstractStrategy.java


示例13: sendMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例14: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String messageBody = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();
	String receiverScreenName = messageBody.substring(0, messageBody.indexOf(' ')).trim();
	messageBody = messageBody.substring(messageBody.indexOf(' '));

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);
	try {
		messageBody = "@"+receiverScreenName+" "+BitlyAPI.shortenUrls(messageBody);
		if(twitter.existsFriendship(receiverScreenName,twitter.getScreenName())){
			if(messageBody.length()<140) {
				StatusUpdate statusUpdate=new StatusUpdate(messageBody);
				statusUpdate.setInReplyToStatusId(twitter.getUserTimeline(receiverScreenName).get(0).getId());
				twitter.updateStatus(statusUpdate);
				replyToMessage(message, "You sent reply to _*" + receiverScreenName +"*_ 's last status.");
			} else {
				replyToMessage(message, "Your message has "+(messageBody.length()-140)+" extra characters.");
			}
		} else {
			replyToMessage(message, "You cannot reply to _*" + receiverScreenName +"*_ 's status.");
		}
	} catch(TwitterException e) {
		/**
		 *  If existsFriendship throws an exception, 
		 *  we know that receiver is a protected non-friend.
		 */
		replyToMessage(message, "You cannot send direct message to _*" + receiverScreenName +"*_.");
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:30,代码来源:ReplyStrategy.java


示例15: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	
	// If no category has been written just inform user on available categories.
	if( message.getBody().equalsIgnoreCase("/quote") ||
		message.getBody().equalsIgnoreCase("/q") ||
		message.getBody().equalsIgnoreCase(".quote") ||
		message.getBody().equalsIgnoreCase(".q") ) {
		replyToMessage(message, "Try giving a category name ( e.g. _*/q love*_ ). " +
				"You can look available categories at http://j.mp/fbSRSr");
		return;
	}
	
	
	String source = message.getBody().trim().substring(
			message.getBody().indexOf(' '), 
			message.getBody().length()).
			trim();

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);
	String quote = "";
	try {
		quote = BitlyAPI.shortenUrls(QuotesAPI.getQuote(source));
		if(!quote.equals("")) {
			twitter.updateStatus(quote);
			replyToMessage(message, "Your quote has been sent:\n_*"+quote+"*_");	
		} else {
			replyToMessage(message, "There is no _*"+source.replace('_', ' ')+"*_ category. " +
					"You can look available categories at http://j.mp/fbSRSr");
		}
	} catch (Exception e) {
		ExceptionPrinter.print(System.err, e, "Boss, I couldn't tweet "+userAccount.getGtalkId()+"'s quote:\n "+quote);
		replyToMessage(message, "I couldn't send your quote.");
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:36,代码来源:QuoteStrategy.java


示例16: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String messageBody = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();
	String receiverScreenName = messageBody.substring(0, messageBody.indexOf(' ')).trim();
	messageBody = messageBody.substring(messageBody.indexOf(' '));

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);
	try {
		messageBody = BitlyAPI.shortenUrls(messageBody);
		if(twitter.existsFriendship(receiverScreenName,twitter.getScreenName())){
			if(messageBody.length()<140) {
				twitter.sendDirectMessage(receiverScreenName, messageBody);
				replyToMessage(message, "You sent direct message to _*" + receiverScreenName +"*_.");
			} else {
				replyToMessage(message, "Your message has "+(messageBody.length()-140)+" extra characters.");
			}
		} else {
			replyToMessage(message, "You cannot send direct message to _*" + receiverScreenName +"*_.");
		}
	} catch(TwitterException e) {
		/**
		 *  If existsFriendship throws an exception, 
		 *  we know that receiver is a protected non-friend.
		 */
		replyToMessage(message, "You cannot send direct message to _*" + receiverScreenName +"*_.");
	}
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:28,代码来源:DirectMessageStrategy.java


示例17: handleMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的package包/类
@Override
public void handleMessage(UserAccount userAccount, Message message) {
	String favoritedScreenName = message.getBody().substring(message.getBody().indexOf(' '), message.getBody().length()).trim();

	Twitter twitter = TwitterAPI.getInstanceFor(userAccount);

	try {
		twitter.createFavorite(twitter.getUserTimeline(favoritedScreenName).get(0).getId());
		replyToMessage(message, "You mark _*"+favoritedScreenName+"*_ 's last status as _favorite_.");
	} catch (TwitterException e) {
		ExceptionPrinter.print(System.err, e, "Boss, I couldn't retweet "+favoritedScreenName+"'s tweet for "+userAccount.getGtalkId());
		replyToMessage(message, "I couldn't mark _*"+favoritedScreenName+"*_ 's last status as _favorite_.");
	}
	
}
 
开发者ID:cansin,项目名称:chitterim,代码行数:16,代码来源:FavoriteStrategy.java


示例18: doPost

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

    log.info("Chat received: " + message.getStanza());

    Entity entity = new Entity("XmppMsg", "test");
    entity.setProperty("type", message.getMessageType().toString());
    entity.setProperty("from", message.getFromJid().toString());
    entity.setProperty("to", message.getRecipientJids()[0].toString());
    entity.setProperty("body", message.getBody());
    datastoreService.put(entity);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:16,代码来源:XmppMessageServlet.java


示例19: doGet

import com.google.appengine.api.xmpp.Message; //导入依赖的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


示例20: sendMessage

import com.google.appengine.api.xmpp.Message; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java FinishedListener类代码示例发布时间:2022-05-22
下一篇:
Java DummyVertxMetrics类代码示例发布时间: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