本文整理汇总了Java中org.jivesoftware.smack.chat.Chat.getParticipant方法的典型用法代码示例。如果您正苦于以下问题:Java Chat.getParticipant方法的具体用法?Java Chat.getParticipant怎么用?Java Chat.getParticipant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.chat.Chat
的用法示例。
在下文中一共展示了Chat.getParticipant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XmppMsg
import org.jivesoftware.smack.chat.Chat; //导入方法依赖的package包/类
public XmppMsg(Chat chat, Message msg) {
this.from = chat.getParticipant();
this.msg = msg.getBody();
Message.Type t = msg.getType();
if (t != null) {
this.type = msg.getType().toString();
}
stanzaId = msg.getStanzaId();
}
示例2: processMessage
import org.jivesoftware.smack.chat.Chat; //导入方法依赖的package包/类
/**
* Process received messages
*/
public void processMessage(Chat chat, Message message) {
XmppMsg xmppMsg = new XmppMsg(chat, message);
invoke("publishXmppMsg", xmppMsg);
Message.Type type = message.getType();
String participant = chat.getParticipant();
String body = message.getBody();
log.info("message of type {} from user {} - {}", type, participant, body);
if (type == Message.Type.chat) {
if (body.startsWith("/")) {
// String pathInfo = String.format("/%s/service%s",
// CodecUtils.PREFIX_API, body); FIXME - wow that was horrific
String pathInfo = String.format("/%s%s", Api.PREFIX_API, body);
try {
org.myrobotlab.framework.Message msg = CodecUri.decodePathInfo(pathInfo);
Object ret = null;
ServiceInterface si = Runtime.getService(msg.name);
if (si == null) {
ret = Status.error("could not find service %s", msg.name);
} else {
ret = si.invoke(msg.method, msg.data);
}
if (ret != null && ret instanceof Serializable) {
// configurable use log or system.out ?
// FIXME - make getInstance configurable
// Encoder
// reference !!!
sendMessage(CodecUtils.toJson(ret), participant);
}
} catch (Exception e) {
try {
Logging.logError(e);
sendMessage(e.toString(), participant);
} catch (Exception e2) {
// give up
}
}
}
} else {
log.error("don't know how to handle message of type {}", type);
}
}