本文整理汇总了Java中org.xmpp.packet.Message.setError方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setError方法的具体用法?Java Message.setError怎么用?Java Message.setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.Message
的用法示例。
在下文中一共展示了Message.setError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bounce
import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void bounce(Message message) {
// Do nothing if the sender was the server itself
if (message.getFrom() == null || message.getFrom().equals( serverAddress )) {
return;
}
try {
// Generate a rejection response to the sender
Message errorResponse = message.createCopy();
// return an error stanza to the sender, which SHOULD be <service-unavailable/>
errorResponse.setError(PacketError.Condition.service_unavailable);
errorResponse.setFrom(message.getTo());
errorResponse.setTo(message.getFrom());
// Send the response
router.route(errorResponse);
// Inform listeners that an offline message was bounced
if (!listeners.isEmpty()) {
for (OfflineMessageListener listener : listeners) {
listener.messageBounced(message);
}
}
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
示例2: sendErrorMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendErrorMessage(String body) {
// Invitation request has failed. Inform inviter
userRequest.removeRelatedRequest(this);
Message message = new Message();
message.setError(PacketError.Condition.recipient_unavailable);
message.setTo(inviter);
message.setFrom(workgroup.getJID());
message.setBody(body);
Element element = message.addChildElement("transfer", "http://jabber.org/protocol/workgroup");
element.addAttribute("type", type.toString());
Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
sessionElement.addAttribute("id", sessionID);
element.addElement("inviter").setText(inviter.toString());
element.addElement("invitee").setText(invitee.toString());
workgroup.send(message);
}
示例3: sendErrorMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendErrorMessage(String body) {
// Invitation request has failed. Inform inviter
userRequest.removeRelatedRequest(this);
Message message = new Message();
message.setError(PacketError.Condition.recipient_unavailable);
message.setTo(inviter);
message.setFrom(workgroup.getJID());
message.setBody(body);
Element element = message.addChildElement("invite", "http://jabber.org/protocol/workgroup");
element.addAttribute("type", type.toString());
Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
sessionElement.addAttribute("id", sessionID);
element.addElement("inviter").setText(inviter.toString());
element.addElement("invitee").setText(invitee.toString());
workgroup.send(message);
}
示例4: bounce
import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void bounce(Message message) {
// Do nothing if the sender was the server itself
if (message.getFrom() == null) {
return;
}
try {
// Generate a rejection response to the sender
Message errorResponse = message.createCopy();
errorResponse.setError(new PacketError(PacketError.Condition.item_not_found,
PacketError.Type.continue_processing));
errorResponse.setFrom(message.getTo());
errorResponse.setTo(message.getFrom());
// Send the response
router.route(errorResponse);
// Inform listeners that an offline message was bounced
if (!listeners.isEmpty()) {
for (OfflineMessageListener listener : listeners) {
listener.messageBounced(message);
}
}
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
示例5: processMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
protected void processMessage(Message packet) throws UnauthorizedException {
if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
// Session is not authenticated so return error
Message reply = new Message();
reply.setID(packet.getID());
reply.setTo(packet.getFrom());
reply.setFrom(packet.getTo());
reply.setError(PacketError.Condition.not_authorized);
session.process(reply);
return;
}
super.processMessage(packet);
}
示例6: processMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
protected void processMessage(Message packet) throws UnauthorizedException {
if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
// Session is not authenticated so return error
Message reply = new Message();
reply.setID(packet.getID());
reply.setTo(packet.getFrom());
reply.setFrom(packet.getTo());
reply.setError(PacketError.Condition.not_authorized);
session.process(reply);
return;
}
super.processMessage(packet);
}
示例7: storeOffline
import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void storeOffline(Message message) {
if (message != null) {
// Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
JID recipientJID = message.getTo();
if (recipientJID == null || serverAddress.equals(recipientJID) ||
recipientJID.getNode() == null ||
!UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
return;
}
// Do not store messages of type groupchat, error or headline as specified in JEP-160
if (Message.Type.groupchat == message.getType() ||
Message.Type.error == message.getType() ||
Message.Type.headline == message.getType()) {
return;
}
// Do not store messages if communication is blocked
PrivacyList list =
PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
if (list != null && list.shouldBlockPacket(message)) {
Message result = message.createCopy();
result.setTo(message.getFrom());
result.setError(PacketError.Condition.service_unavailable);
XMPPServer.getInstance().getRoutingTable().routePacket(message.getFrom(), result, true);
return;
}
if (type == Type.bounce) {
bounce(message);
}
else if (type == Type.store) {
store(message);
}
else if (type == Type.store_and_bounce) {
if (underQuota(message)) {
store(message);
}
else {
bounce(message);
}
}
else if (type == Type.store_and_drop) {
if (underQuota(message)) {
store(message);
}
}
}
}