本文整理汇总了Java中org.xmpp.packet.Presence.getShow方法的典型用法代码示例。如果您正苦于以下问题:Java Presence.getShow方法的具体用法?Java Presence.getShow怎么用?Java Presence.getShow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.Presence
的用法示例。
在下文中一共展示了Presence.getShow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPresence
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
@Override
public Presence getPresence(User user) {
if (user == null) {
return null;
}
Presence presence = null;
for (ClientSession session : sessionManager.getSessions(user.getUsername())) {
if (presence == null) {
presence = session.getPresence();
}
else {
// Get the ordinals of the presences to compare. If no ordinal is available then
// assume a value of -1
int o1 = presence.getShow() != null ? presence.getShow().ordinal() : -1;
int o2 = session.getPresence().getShow() != null ?
session.getPresence().getShow().ordinal() : -1;
// Compare the presences' show ordinals
if (o1 > o2) {
presence = session.getPresence();
}
}
}
return presence;
}
示例2: sendInfo
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
@Override
public void sendInfo(HttpServletRequest request,
HttpServletResponse response, Presence presence) throws IOException {
if (presence == null) {
writeImageContent(request, response, "offline", servlet.offline);
}
else if (presence.getShow() == null) {
writeImageContent(request, response, "available", servlet.available);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.away)) {
writeImageContent(request, response, "away", servlet.away);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.chat)) {
writeImageContent(request, response, "chat", servlet.chat);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.dnd)) {
writeImageContent(request, response, "dnd", servlet.dnd);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.xa)) {
writeImageContent(request, response, "xa", servlet.xa);
}
}
示例3: getPresence
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
public Presence getPresence(User user) {
if (user == null) {
return null;
}
Presence presence = null;
for (ClientSession session : sessionManager.getSessions(user.getUsername())) {
if (presence == null) {
presence = session.getPresence();
}
else {
// Get the ordinals of the presences to compare. If no ordinal is available then
// assume a value of -1
int o1 = presence.getShow() != null ? presence.getShow().ordinal() : -1;
int o2 = session.getPresence().getShow() != null ?
session.getPresence().getShow().ordinal() : -1;
// Compare the presences' show ordinals
if (o1 > o2) {
presence = session.getPresence();
}
}
}
return presence;
}
示例4: sendInfo
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
@Override
public void sendInfo(HttpServletRequest request,
HttpServletResponse response, Presence presence) throws IOException {
if (presence == null) {
writeImageContent(request, response, "offline", servlet.offline);
}
else if (presence.getShow() == null) {
writeImageContent(request, response, "available", servlet.available);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.away)) {
writeImageContent(request, response, "away", servlet.away);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.chat)) {
writeImageContent(request, response, "chat", servlet.chat);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.dnd)) {
writeImageContent(request, response, "dnd", servlet.dnd);
}
else if (presence.getShow().equals(org.xmpp.packet.Presence.Show.xa)) {
writeImageContent(request, response, "xa", servlet.xa);
}
}
示例5: updatePresence
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
private void updatePresence(ClientSession session, Presence presence)
{
Connection con = null;
PreparedStatement pstmt = null;
final String presenceText;
if (!XMPPServer.getInstance().getUserManager().isRegisteredUser(session.getAddress()))
{
return;
}
if (Presence.Type.unavailable.equals(presence.getType()))
{
presenceText = presence.getType().toString();
}
else if (presence.getShow() != null)
{
presenceText = presence.getShow().toString();
}
else if (presence.isAvailable())
{
presenceText = "available";
}
else
{
return;
}
setPresence(session, presenceText);
}
示例6: sendNotify
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
public void sendNotify(Dialog dialog) throws ParseException, SipException, InvalidArgumentException {
Request notifyRequest = prepareNotifyRequest(dialog);
try {
User me = XMPPServer.getInstance().getUserManager().getUser(getJID().getNode());
Presence myPresence = XMPPServer.getInstance().getPresenceManager().getPresence(me);
String presenceContent;
SimplePresence simplePresence = new SimplePresence();
simplePresence.setEntity("pres:" + registration.getUsername() + "@" + sipHost);
simplePresence.setDmNote(myPresence.getStatus());
if (myPresence.getStatus() != null && myPresence.getStatus().equalsIgnoreCase("Offline"))
simplePresence.setTupleStatus(SimplePresence.TupleStatus.CLOSED);
else {
simplePresence.setTupleStatus(SimplePresence.TupleStatus.OPEN);
if (myPresence.getShow() != null) {
switch (myPresence.getShow()) {
case away:
simplePresence.setRpid(SimplePresence.Rpid.AWAY);
break;
case dnd:
simplePresence.setRpid(SimplePresence.Rpid.BUSY);
break;
case xa:
simplePresence.setRpid(SimplePresence.Rpid.AWAY);
break;
default:
break;
}
}
}
presenceContent = simplePresence.toXML();
ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("application", "pidf+xml");
notifyRequest.setContent(presenceContent, contentTypeHeader);
}
catch (Exception e) {
Log.debug("Unable to include presence details in the packet.", e);
}
sendRequest(notifyRequest, ListeningPoint.UDP, dialog);
}
示例7: sendNotify
import org.xmpp.packet.Presence; //导入方法依赖的package包/类
public void sendNotify(Dialog dialog) throws ParseException, SipException, InvalidArgumentException {
Request notifyRequest = prepareNotifyRequest(dialog);
try {
User me = XMPPServer.getInstance().getUserManager().getUser(getJID().getNode());
Presence myPresence = XMPPServer.getInstance().getPresenceManager().getPresence(me);
String presenceContent;
SimplePresence simplePresence = new SimplePresence();
simplePresence.setEntity("pres:" + registration.getUsername() + "@" + sipHost);
simplePresence.setDmNote(myPresence.getStatus());
if (myPresence.getStatus() != null && myPresence.getStatus().equalsIgnoreCase("Offline"))
simplePresence.setTupleStatus(SimplePresence.TupleStatus.CLOSED);
else {
simplePresence.setTupleStatus(SimplePresence.TupleStatus.OPEN);
if (myPresence.getShow() != null) {
switch (myPresence.getShow()) {
case away:
simplePresence.setRpid(SimplePresence.Rpid.AWAY);
break;
case dnd:
simplePresence.setRpid(SimplePresence.Rpid.BUSY);
break;
case xa:
simplePresence.setRpid(SimplePresence.Rpid.AWAY);
break;
default:
break;
}
}
}
presenceContent = simplePresence.toXML();
ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("application", "pidf+xml");
notifyRequest.setContent(presenceContent, contentTypeHeader);
}
catch (Exception e) {
Log.debug("Unable to include presence details in the packet.", e);
}
sendRequest(notifyRequest, ListeningPoint.UDP, dialog);
}