本文整理汇总了Java中org.apache.vysper.xmpp.addressing.EntityFormatException类的典型用法代码示例。如果您正苦于以下问题:Java EntityFormatException类的具体用法?Java EntityFormatException怎么用?Java EntityFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityFormatException类属于org.apache.vysper.xmpp.addressing包,在下文中一共展示了EntityFormatException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyCredentials
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
@Override
public boolean verifyCredentials(String username, String passwordCleartext, Object credentials) {
try {
Entity jid = EntityImpl.parse(username);
return verifyCredentials(jid, passwordCleartext, credentials);
} catch (EntityFormatException e) {
LOG.error("Parse JID failed", e);
}
return false;
}
示例2: retrieveRoster
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
@Override public Roster retrieveRoster(Entity jid) {
Uid uid = new Uid(jid.toString());
MutableRoster roster = new MutableRoster();
List<TinyUser> users = loadCacheUsers();
if (null == users || users.size() < 1) {
return roster;
}
for (TinyUser u : users) {
// 忽略当前账户
if (u.account.equals(uid.getAccount())) {
continue;
}
try {
Entity ujid = EntityImpl.parse(u.account + "@" + uid.getDomain());
List<RosterGroup> groups = Lists.newArrayList();
String groupName = u.getGroupName();
if (null != groupName) {
groups.add(new RosterGroup(groupName));
}
RosterItem rosterItem = new RosterItem(
ujid,
u.name,
SubscriptionType.BOTH,
AskSubscriptionType.NOT_SET,
groups);
roster.addItem(rosterItem);
} catch (EntityFormatException e) {
LOG.error("method:retrieveRoster,jid:" + jid + ",errorMsg:" + e.getMessage(), e);
}
}
return roster;
}
示例3: createAckMessageStanza
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
/**
* Create Ack Message
<message id="">
<gcm xmlns="google:mobile:data">
{
"from":"REGID",
"message_id":"m-1366082849205"
"message_type":"ack"
}
</gcm>
</message>
* @param original
* @param jsonObject
* @return
* @throws EntityFormatException
*/
private static Stanza createAckMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
Map<String, Object> message = new HashMap<>();
message.put(JSON_MESSAGE_TYPE, JSON_ACK);
message.put(JSON_FROM, jsonObject.get(JSON_TO));
message.put(JSON_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
String payload = JSONValue.toJSONString(message);
// no from & to
StanzaBuilder builder = new StanzaBuilder("message");
builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
gcmMessageBuilder.addText(payload);
builder.addPreparedElement(gcmMessageBuilder.build());
return builder.build();
}
示例4: createNackBadRegIdMessageStanza
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
/**
* Create Bad RegId Nack Message Stanza
*
<message>
<gcm xmlns="google:mobile:data">
{
"message_type":"nack",
"message_id":"msgId1",
"from":"SomeInvalidRegistrationId",
"error":"BAD_REGISTRATION",
"error_description":"Invalid token on 'to' field: SomeInvalidRegistrationId"
}
</gcm>
</message>
* @param original
* @param jsonObject
* @return
* @throws EntityFormatException
*/
private static Stanza createNackBadRegIdMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
Map<String, Object> message = new HashMap<>();
message.put(JSON_MESSAGE_TYPE, JSON_NACK);
message.put(JSON_FROM, jsonObject.get(JSON_TO));
message.put(JSON_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
message.put(JSON_ERROR, JSON_ERROR_BAD_REGISTRATION);
message.put(JSON_ERROR_DESCRIPTION, "Invalid token on 'to' field: "+jsonObject.get(JSON_TO));
String payload = JSONValue.toJSONString(message);
StanzaBuilder builder = new StanzaBuilder("message");
builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
gcmMessageBuilder.addText(payload);
builder.addPreparedElement(gcmMessageBuilder.build());
return builder.build();
}
示例5: createDeliveryReceiptMessageStanza
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
/**
* Create Delivery Receipt
<message id="">
<gcm xmlns="google:mobile:data">
{
"category":"com.example.yourapp", // to know which app sent it
"data":
{
“message_status":"MESSAGE_SENT_TO_DEVICE",
“original_message_id”:”m-1366082849205”,
“device_registration_id”: “REGISTRATION_ID”,
"message_sent_timestamp": "1430277821658"
},
"message_id":"dr2:m-1366082849205",
"message_type":"receipt",
"time_to_live": 0,
"from":"gcm.googleapis.com"
}
</gcm>
</message>
* @param original
* @param jsonObject
* @return
* @throws EntityFormatException
*/
private static Stanza createDeliveryReceiptMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
Map<String, Object> message = new HashMap<>();
message.put(JSON_MESSAGE_TYPE, JSON_RECEIPT);
message.put(JSON_FROM, "gcm.googleapis.com");
// TODO made up
message.put(JSON_CATEGORY, "com.itsoninc.client");
message.put(JSON_MESSAGE_ID, "dr2:"+jsonObject.get(JSON_MESSAGE_ID));
Map<String, Object> data = new HashMap<>();
data.put(JSON_MESSAGE_STATUS, JSON_MESSAGE_STATUS_SENT_TO_DEVICE);
data.put(JSON_ORIGINAL_MESSAGE_ID, jsonObject.get(JSON_MESSAGE_ID));
data.put(JSON_DEVICE_REG_ID, jsonObject.get(JSON_TO));
data.put(JSON_SENT_TIMESTAMP, Long.toString(System.currentTimeMillis()));
message.put("data", data);
String payload = JSONValue.toJSONString(message);
StanzaBuilder builder = new StanzaBuilder("message");
builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
gcmMessageBuilder.addText(payload);
builder.addPreparedElement(gcmMessageBuilder.build());
return builder.build();
}
示例6: createDrainingMessageStanza
import org.apache.vysper.xmpp.addressing.EntityFormatException; //导入依赖的package包/类
/**
* Create Draining Control Message
<message>
<data:gcm xmlns:data="google:mobile:data">
{
"message_type":"control"
"control_type":"CONNECTION_DRAINING"
}
</data:gcm>
</message>
* @param original
* @param jsonObject
* @return
* @throws EntityFormatException
*/
private static Stanza createDrainingMessageStanza(Stanza original, JSONObject jsonObject) throws EntityFormatException {
Map<String, Object> message = new HashMap<>();
message.put(JSON_MESSAGE_TYPE, JSON_CONTROL);
message.put(JSON_CONTROL_TYPE, "CONNECTION_DRAINING");
String payload = JSONValue.toJSONString(message);
StanzaBuilder builder = new StanzaBuilder("message");
builder.addAttribute("id", original.getAttributeValue("id") == null ? "": original.getAttributeValue("id"));
GCMMessage.Builder gcmMessageBuilder = new GCMMessage.Builder();
gcmMessageBuilder.addText(payload);
builder.addPreparedElement(gcmMessageBuilder.build());
return builder.build();
}