`

[原创]使用Smack库实现Google Talk XMPP Extensions - Gmail Notifications (含完整的实现代码以及例子)

    博客分类:
  • XMPP
阅读更多
注意: 这里有本人所写的完整的代码, 所以如果要转载, 请征得本人同意然后加上原文出处; 如果使用代码, 只需要加上本文的Link就可以了.

Gmail Notifications的是Google Talk XMPP Extensions其中之一, 它的用途是Gmail服务器有新邮件的时候, 会通过XMPP协议Push给客户端, 然后客户端可以通过XMPP协议去查询新邮件的信息, 包括新邮件的标题,摘要,发件人邮件地址等.

这个功能其实GTalk客户端已经有了, 但既然已经有了标准的文档, 何不妨把这个功能也加到自己的IM客户端上呢. 当然这个Extension只能用于GTalk服务器.

关于这个Extension的介绍, 请看Google的文档:
http://code.google.com/intl/zh-CN/apis/talk/jep_extensions/gmail.html

下面就直接上传代码, 代码不介绍了, 对照文档应该很好理解的, 其实也很简单.

package com.hj.smack.demo.gmailnotif;

import org.jivesoftware.smack.packet.IQ;

public class EmailNotification extends IQ {
	@Override
	public String getChildElementXML() {
		StringBuilder buf = new StringBuilder();
		buf.append("<new-mail xmlns=\"").append("google:mail:notify").append("\"");
		buf.append("/>");
		return buf.toString();
	}
}


package com.hj.smack.demo.gmailnotif;

import org.jivesoftware.smack.packet.IQ;

public class EmailQueryRequest extends IQ {
	
	private Long newerThanTime;
	private Long newThanTid;
	private String query;
	
	@Override
	public String getChildElementXML() {
		StringBuilder buf = new StringBuilder();
		buf.append("<query xmlns=\"").append("google:mail:notify").append("\"");
		if (newerThanTime != null) {
			buf.append(" newer-than-time=\"").append(newerThanTime).append("\"");
		}
		if (newThanTid != null) {
			buf.append(" newer-than-tid=\"").append(newThanTid).append("\"");
		}
		if (query != null) {
			buf.append(" q=\"").append(query).append("\"");
		}
		buf.append("/>");
		return buf.toString();
	}

	public void setNewerThanTime(Long newerThanTime) {
		this.newerThanTime = newerThanTime;
	}

	public Long getNewerThanTime() {
		return newerThanTime;
	}
	public void setNewThanTid(Long newThanTid) {
		this.newThanTid = newThanTid;
	}
	public Long getNewThanTid() {
		return newThanTid;
	}
	public void setQuery(String query) {
		this.query = query;
	}
	public String getQuery() {
		return query;
	}
}


package com.hj.smack.demo.gmailnotif;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.jivesoftware.smack.packet.IQ;

public class EmailQueryResponse extends IQ {	
	private Mailbox mailbox;
	
	@Override
	public String getChildElementXML() {
		StringBuilder buf = new StringBuilder();
		if (mailbox != null) {
			buf.append(mailbox.toXML());
		}
		return buf.toString();
	}
	
	public Mailbox getMailbox() {
		return mailbox;
	}
	public void setMailbox(Mailbox mailbox) {
		this.mailbox = mailbox;
	}
	
	public static class Mailbox {
		private Long resultTime;
		private Integer totalMatched;
		private Boolean totalEstimated;
		private String url;
		private List<MailThreadInfo> mailThreadInfos = new CopyOnWriteArrayList<MailThreadInfo>();
		
		public String toXML() {
			StringBuilder buf = new StringBuilder();
			buf.append("<mailbox xmlns=\"").append("google:mail:notify").append("\"");
			buf.append(" result-time=\"").append(resultTime).append("\"");
			buf.append(" total-matched=\"").append(totalMatched).append("\"");
			if (totalEstimated != null) {
				if (totalEstimated) {
					buf.append(" total-estimate=\"").append("1").append("\"");
				} else {
					buf.append(" total-estimate=\"").append("0").append("\"");
				}
			}
			buf.append(">");
			synchronized (mailThreadInfos) {
				for (MailThreadInfo mailThreadInfo : mailThreadInfos) {
					buf.append(mailThreadInfo.toXML());
				}
			}
			buf.append("</mailbox>");
            return buf.toString();
		}
		
		public void addMailThreadInfo(MailThreadInfo mailThreadInfo) {
			synchronized (mailThreadInfos) {
				mailThreadInfos.add(mailThreadInfo);
	        }
		}
		
		public Iterator<MailThreadInfo> getMailThreadInfos() {
			synchronized (mailThreadInfos) {
	            return Collections.unmodifiableList(mailThreadInfos).iterator();
	        }
		}
		
		public Long getResultTime() {
			return resultTime;
		}
		public void setResultTime(Long resultTime) {
			this.resultTime = resultTime;
		}
		public Integer getTotalMatched() {
			return totalMatched;
		}
		public void setTotalMatched(Integer totalMatched) {
			this.totalMatched = totalMatched;
		}
		public Boolean getTotalEstimated() {
			return totalEstimated;
		}
		public void setTotalEstimated(Boolean totalEstimated) {
			this.totalEstimated = totalEstimated;
		}
		public String getUrl() {
			return url;
		}
		public void setUrl(String url) {
			this.url = url;
		}
		
		public static class MailThreadInfo {
			private Long tid;
			private Integer participation;
			private Integer messages;
			private Long date;
			private String url;
			private String labels;
			private String subject;
			private String snippet;
			private List<Sender> senders = new CopyOnWriteArrayList<Sender>();
			
			public String toXML() {
				StringBuilder buf = new StringBuilder();
				buf.append("<mail-thread-info tid=\"").append(tid).append("\"");
				buf.append(" participation=\"").append(participation).append("\"");
				buf.append(" date=\"").append(date).append("\"");
				buf.append(" url=\"").append(url).append("\"");
				buf.append(">");
				buf.append("<senders>");
				synchronized (senders) {
					for (Sender sender : senders) {
						buf.append(sender.toXML());
					}
				}
				buf.append("</senders>");
				buf.append("<labels>").append(labels).append("</labels>");
				buf.append("<subject>").append(subject).append("</subject>");
				buf.append("<snippet>").append(snippet).append("</snippet>");
				buf.append("</mail-thread-info>");
	            return buf.toString();
			}
			
			public void addSender(Sender sender) {
				synchronized (senders) {
					senders.add(sender);
		        }
			}
			
			public Iterator<Sender> getSenders() {
				synchronized (senders) {
		            return Collections.unmodifiableList(senders).iterator();
		        }
			}
			
			public String getLabels() {
				return labels;
			}
			public void setLabels(String labels) {
				this.labels = labels;
			}
			public String getSubject() {
				return subject;
			}
			public void setSubject(String subject) {
				this.subject = subject;
			}
			public String getSnippet() {
				return snippet;
			}
			public void setSnippet(String snippet) {
				this.snippet = snippet;
			}
			public Long getTid() {
				return tid;
			}
			public void setTid(Long tid) {
				this.tid = tid;
			}
			public Integer getParticipation() {
				return participation;
			}
			public void setParticipation(Integer participation) {
				this.participation = participation;
			}
			public Integer getMessages() {
				return messages;
			}
			public void setMessages(Integer messages) {
				this.messages = messages;
			}
			public Long getDate() {
				return date;
			}
			public void setDate(Long date) {
				this.date = date;
			}
			public String getUrl() {
				return url;
			}
			public void setUrl(String url) {
				this.url = url;
			}
			
			public static class Sender {
				private String name;
				private String address;
				private Boolean originator;
				private Boolean unread;
				
				public String toXML() {
					StringBuilder buf = new StringBuilder();
					buf.append("<sender name=\"").append(name).append("\"");
					buf.append(" address=\"").append(address).append("\"");
					if (originator != null) {
						if (originator) {
							buf.append(" originator=\"").append("1").append("\"");
						} else {
							buf.append(" originator=\"").append("0").append("\"");
						}
					}
					if (unread != null) {
						if (unread) {
							buf.append(" unread=\"").append("1").append("\"");
						} else {
							buf.append(" unread=\"").append("0").append("\"");
						}
					}
					buf.append("/>");
		            return buf.toString();
				}
				
				public String getName() {
					return name;
				}
				public void setName(String name) {
					this.name = name;
				}
				public String getAddress() {
					return address;
				}
				public void setAddress(String address) {
					this.address = address;
				}
				public Boolean getOriginator() {
					return originator;
				}
				public void setOriginator(Boolean originator) {
					this.originator = originator;
				}
				public Boolean getUnread() {
					return unread;
				}
				public void setUnread(Boolean unread) {
					this.unread = unread;
				}
			}
		}
	}
}


package com.hj.smack.demo.gmailnotif;

import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;

public class GmailNotificationManager {

	private XMPPConnection connection;
	private GmailNotificationListener listener;
	
	public GmailNotificationManager(XMPPConnection connection) {
		 this.connection = connection;
	     init();
	}
	
	private void init() {
		// Listen for new-email notification
		PacketFilter packetFilter = new PacketTypeFilter(EmailNotification.class);
		PacketListener packetListener = new PacketListener() {
            public void processPacket(Packet packet) {
            	EmailNotification notif = (EmailNotification)packet;
            	// Notify registered listener
            	if (listener != null) {
            		listener.hasNewEmail();
            	}
            	
            	// Should respond to the server
            	IQ req = new IQ() {
					@Override
					public String getChildElementXML() {
						return null;
					}
            	};
        		req.setType(IQ.Type.RESULT);
        		req.setFrom(notif.getTo());
        		req.setTo(notif.getFrom());
        		req.setPacketID(notif.getPacketID());
                
                connection.sendPacket(req);
            }
		};
		connection.addPacketListener(packetListener, packetFilter);
	}
	
	public void setGmailNotificationListener(GmailNotificationListener listener) {
		this.listener = listener;
	}
	
	public EmailQueryResponse.Mailbox checkMailbox(String jid) throws XMPPException {
		EmailQueryRequest req = new EmailQueryRequest();
		req.setType(IQ.Type.GET);
		String bare = StringUtils.parseBareAddress(jid);
		req.setFrom(jid);
		req.setTo(bare);
		
		// Create a packet collector to listen for a response.
        PacketCollector collector =
            connection.createPacketCollector(new PacketIDFilter(req.getPacketID()));
        
        connection.sendPacket(req);
        
        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
       collector.cancel();
        
        if (result == null) {
            throw new XMPPException("No response from the server.");
        }
        if (result.getType() == IQ.Type.ERROR) {
            throw new XMPPException(result.getError());
        }
        return ((EmailQueryResponse) result).getMailbox();
	}
	
	public static interface GmailNotificationListener {
		public void hasNewEmail();
	}
}


package com.hj.smack.demo.gmailnotif;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;


public class GmailNotificationProvider implements IQProvider {

	@Override
	public IQ parseIQ(XmlPullParser parser) throws Exception {
		EmailQueryResponse gmailQueryResp = null;
		EmailNotification gmailNotif = null;
		boolean done = false;
		EmailQueryResponse.Mailbox mailbox = null;
		EmailQueryResponse.Mailbox.MailThreadInfo mailThreadInfo = null;
		EmailQueryResponse.Mailbox.MailThreadInfo.Sender sender = null;
		
		// Cache the text
		String cachedText = "";
		
		// Mailbox attributes
		String resultTime = "";
		String totalMatched = "";
		String totalEstimated = null;
		String mailboxUrl = "";
		
		// MailThreadInfo attributes
		String tid = "";
		String participation = "";
		String messages = "";
		String date = "";
		String mailThreadInfoUrl = "";
		String labels = "";
		String subject = "";
		String snippet = "";
		
		// Sender attributes
		String name = "";
		String address = "";
		String originator = null;
		String unread = null;
		
		if (parser.getName().equals("new-mail")) {
			gmailNotif = new EmailNotification();
		} else {
			// Initialize the variables from the parsed XML
			resultTime = parser.getAttributeValue("", "result-time");
			totalMatched = parser.getAttributeValue("", "total-matched");
			totalEstimated = parser.getAttributeValue("", "total-estimate");
			mailboxUrl = parser.getAttributeValue("", "mailboxUrl");

			// Create a new Mailbox and add it to the GmailNotifications
			gmailQueryResp = new EmailQueryResponse();
			mailbox = new EmailQueryResponse.Mailbox();
			mailbox.setResultTime(Long.parseLong(resultTime));
			mailbox.setTotalMatched(Integer.parseInt(totalMatched));
			mailbox.setTotalEstimated(totalEstimated != null ? Boolean.parseBoolean(totalEstimated) : null);
			mailbox.setUrl(mailboxUrl);
			gmailQueryResp.setMailbox(mailbox);
		}
		
		while (!done) {
			int eventType = parser.next();
			if (eventType == XmlPullParser.START_TAG) {
				if (parser.getName().equals("mail-thread-info")) {
					// Initialize the variables from the parsed XML
					tid = parser.getAttributeValue("", "tid");
					participation = parser.getAttributeValue("",
							"participation");
					messages = parser.getAttributeValue("", "messages");
					date = parser.getAttributeValue("", "date");
					mailThreadInfoUrl = parser.getAttributeValue("", "url");

					// Create a new MailThreadInfo and add it to the Mailbox
					mailThreadInfo = new EmailQueryResponse.Mailbox.MailThreadInfo();
					mailThreadInfo.setTid(Long.parseLong(tid));
					mailThreadInfo.setParticipation(Integer.parseInt(participation));
					mailThreadInfo.setMessages(Integer.parseInt(messages));
					mailThreadInfo.setDate(Long.parseLong(date));
					mailThreadInfo.setUrl(mailThreadInfoUrl);
					mailbox.addMailThreadInfo(mailThreadInfo);
				} else if (parser.getName().equals("sender")) {
					// Initialize the variables from the parsed XML
					name = parser.getAttributeValue("", "name");
					address = parser.getAttributeValue("", "address");
					originator = parser.getAttributeValue("", "originator");
					unread = parser.getAttributeValue("", "unread");

					// Create a new Sender and add it to the MailThreadInfo
					sender = new EmailQueryResponse.Mailbox.MailThreadInfo.Sender();
					sender.setName(name);
					sender.setAddress(address);
					sender.setOriginator(originator != null ? Boolean.parseBoolean(totalEstimated) : null);
					sender.setUnread(unread != null ? Boolean.parseBoolean(unread) : null);
					mailThreadInfo.addSender(sender);
				}
			} else if (eventType == XmlPullParser.TEXT) {
				cachedText = parser.getText();
			} else if (eventType == XmlPullParser.END_TAG) {
				if (parser.getName().equals("new-mail") || parser.getName().equals("mailbox")) {
					done = true;
				} else if (parser.getName().equals("mail-thread-info")) {
				} else if (parser.getName().equals("sender")) {
				} else if (parser.getName().equals("labels")) {
					labels = cachedText;
					mailThreadInfo.setLabels(labels);
				} else if (parser.getName().equals("subject")) {
					subject = cachedText;
					mailThreadInfo.setSubject(subject);
				} else if (parser.getName().equals("snippet")) {
					snippet = cachedText;
					mailThreadInfo.setSnippet(snippet);
				}
			}
		}

		if (gmailNotif != null) {
			return gmailNotif;
		} else {
			return gmailQueryResp;
		}
	}
}


例子程序
package com.hj.smack.demo;

import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.provider.ProviderManager;

import com.hj.smack.demo.gmailnotif.EmailQueryResponse;
import com.hj.smack.demo.gmailnotif.GmailNotificationManager;
import com.hj.smack.demo.gmailnotif.GmailNotificationProvider;
import com.hj.smack.demo.gmailnotif.GmailNotificationManager.GmailNotificationListener;

public class GmailNotifTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		XMPPConnection.DEBUG_ENABLED = false;
		
		ProviderManager providerManager = ProviderManager.getInstance();
		providerManager.addIQProvider("mailbox", "google:mail:notify", new GmailNotificationProvider());
		providerManager.addIQProvider("new-mail", "google:mail:notify", new GmailNotificationProvider());
		
	    ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
		config.setCompressionEnabled(true);
		config.setSASLAuthenticationEnabled(true);

		XMPPConnection connection = new XMPPConnection(config);
		try {
			connection.connect();

		    connection.login("xxxxxx@gmail.com", "*******");
			demoGmailNotif(connection);
			Thread.sleep(500000);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			connection.disconnect();
		}
	}
	
	public static void demoGmailNotif(XMPPConnection connection) {
		String my = connection.getUser();
		GmailNotificationManager m = new GmailNotificationManager(connection);
		m.setGmailNotificationListener(new MyGmailNotificationListener(connection));
		
		try {
			EmailQueryResponse.Mailbox mailbox = m.checkMailbox(my);
			System.out.println(mailbox.toXML());	
		} catch (XMPPException e) {
			e.printStackTrace();
		}
	}
	
	private static class MyGmailNotificationListener implements GmailNotificationListener {

		private XMPPConnection connection;
		public MyGmailNotificationListener(XMPPConnection connection) {
			this.connection = connection;
		}
		
		@Override
		public void hasNewEmail() {
			System.out.println("You have new emails in your gmail inbox!");	
			
			String my = connection.getUser();
			GmailNotificationManager m = new GmailNotificationManager(connection);
			EmailQueryResponse.Mailbox mailbox;
			try {
				mailbox = m.checkMailbox(my);
				System.out.println(mailbox.toXML());	
			} catch (XMPPException e) {
				e.printStackTrace();
			}
		}
	}
}

分享到:
评论
4 楼 laiyangdeli 2011-08-15  
bluky999 写道
浏览了一下LZ的日志,尤其是XMPP分类下的,看来对XMPP/jabber openfire ejabberd ,spark psi 等都了解了一遍; 猜想LZ当时也是在参与什么IM系统构建相关的项目吧?!

想问下,LZ最后有无开发相关的产品出来? 比如目前流行的多人语音聊天的移动app啊之类的?  如果有的话,那么服务端的技术选型和技术架构是怎么样的?可否简单做介绍?我最近你也在关注这个方向 


我工作的方向并不是XMPP等,只是兴趣。现在工作比较忙,已经好久没研究这个了。
3 楼 bluky999 2011-08-15  
浏览了一下LZ的日志,尤其是XMPP分类下的,看来对XMPP/jabber openfire ejabberd ,spark psi 等都了解了一遍; 猜想LZ当时也是在参与什么IM系统构建相关的项目吧?!

想问下,LZ最后有无开发相关的产品出来? 比如目前流行的多人语音聊天的移动app啊之类的?  如果有的话,那么服务端的技术选型和技术架构是怎么样的?可否简单做介绍?我最近你也在关注这个方向 
2 楼 laiyangdeli 2011-02-22  
smildlzj 写道
不错,恰巧前段时间也实现了...不过没你那么长..也没你那么完善


我是按照Smack的style来实现这个extension的.
1 楼 smildlzj 2011-02-21  
不错,恰巧前段时间也实现了...不过没你那么长..也没你那么完善

相关推荐

    smack 4.1.6 实现xmpp所需要的所有jar jxmpp

    2. smack-extensions-4.1.6-sources.jar:源代码库,开发者可以查看和学习Smack扩展库的实现细节。 3. smack-legacy-4.1.6-javadoc.jar:Smack遗留组件的API文档,帮助开发者理解那些仍保留但可能不再推荐使用的API...

    smack4.1.5 实现xmpp 所需要的所有jar

    Smack 4.1.5 是一个开源的Java库,用于实现XMPP(Extensible Messaging and Presence Protocol)协议。XMPP是一种基于XML的实时通信协议,广泛用于即时通讯、在线状态管理和多用户聊天等场景。在Java应用中,Smack库...

    smack-resolver-dnsjava-4.0.0-rc2.zip

    1. **Smack**:Smack 是一个高度灵活且易于使用的 Java 库,用于实现 XMPP 协议。XMPP 是一种基于 XML 的协议,广泛应用于即时通讯、聊天、VoIP、协作等多种场景。Smack 提供了连接、认证、会话管理、消息传递、多...

    smack-extensions-4.1.0-alpha3.zip

    【标题】"smack-extensions-4.1.0-alpha3.zip" 提供的是 Smack 开源库的一个扩展包,版本为4.1.0的Alpha3版本。Smack 是一个用于XMPP(Extensible Messaging and Presence Protocol)的Java库,它允许开发者在Java...

    android下的XMPP对应smack-4.2.1,实现登录,注册,发单聊,加聊天室,发群聊等简单功能

    在这个项目中,我们利用Smack-4.2.1库来实现在Android上使用XMPP进行各种交互,如登录、注册、发送单聊消息、加入聊天室和发送群聊消息等基本功能。 首先,我们需要了解Smack-4.2.1。Smack是一个开源的Java库,专门...

    Android使用smack连接ejabberd服务器注册、收发消息

    implementation 'org.igniterealtime.smack:smack-extensions:4.3.5' } ``` **二、连接ejabberd服务器** 连接ejabberd服务器需要创建XMPPTCPConnection对象。以下代码展示了如何建立连接: ```java ...

    smack-resolver-javax-4.1.0-alpha6.zip

    标题中的"smack-resolver-javax-4.1.0-alpha6.zip"是一个软件库的压缩包,Smack是一款开源的XMPP客户端库,而"javax"可能指的是它提供了与Java平台兼容的解析器组件。这个版本是4.1.0的Alpha6,意味着它是一个开发...

    xmpp客户端协议实现源代码

    本资源包含了一个名为"smack"的库的源代码,该库是实现XMPP客户端协议的一个流行选择。让我们深入探讨一下SMACK库和XMPP协议的相关知识点。 **SMACK库** 1. **SMACK简介**:SMACK是Simple XMPP Client Library for...

    XMPP Smack java 聊天程序

    Smack是XMPP的一个Java实现库,它为开发者提供了简单易用的API,方便构建XMPP应用。 在"XMPP Smack java 聊天程序"这个项目中,你将学习到如何使用Smack库在Java环境中创建一个基本的聊天应用。首先,你需要理解...

    Android-XMPP-openfire-实现IM

    - **Smack库**:在Android中,开发者通常使用Smack库来实现XMPP协议,它提供了API用于连接Openfire服务器,发送和接收消息。 - **连接管理**:客户端需要建立与Openfire服务器的连接,处理登录、心跳保活、断线重...

    xmpp——Smack的IM实现

    在本文档的"trunk"子文件中,可能包含了Smack库的源代码、示例项目或者相关的文档资源,这些都可以帮助开发者深入理解和使用Smack,从而更好地实现XMPP协议的IM功能。通过阅读源码和示例,可以学习到如何配置连接...

    smack4.1.6连接openfire,tigase,ejabberd所需jar包

    jxmpp-core-0.5.0-alpha7 jxmpp-util-cache-0.5.0-alpha7 smack-android-4.1.6 smack-core-4.1.6 smack-extensions-4.1.6 smack-im-4.1.6 smack-sasl-provided-4.1.6 smack-tcp-4.1.6

    smack4.3.1

    Smack 是一个开源的、跨平台的即时通讯(IM)库,专为实现XMPP(Extensible Messaging and Presence Protocol)协议而设计。在Smack 4.3.1版本中,开发者能够利用这个强大的框架为Android移动端构建高效、安全的聊天...

    AndroidXMPP-master

    这个名为"AndroidXMPP-master"的项目显然是一个针对Android平台的XMPP客户端实现,包含了实现XMPP功能所需的全部源代码和资源。 在Android平台上开发XMPP应用,你需要理解以下几个核心知识点: 1. **XMPP协议**:...

    基于smack连接openfire服务器的例子-JAVA

    本文将深入探讨如何使用Smack库,一个Java实现的XMPP客户端库,来连接到Openfire服务器并进行交互。Smack简化了与XMPP服务器的通信,提供了丰富的API来处理用户认证、会话管理、消息发送和接收、以及用户状态等。 ...

    smack与asmack的区别(包名对比解析)

    Smack的目标是提供一个稳定可靠、易于使用的XMPP客户端实现,使得开发者能够快速地构建出功能强大的IM应用。 ##### 主要特点: 1. **广泛的兼容性**:Smack支持从Java SE到Android的各种Java运行环境,适用于不同的...

    安卓xmpp通讯之smack4.1.9

    在Android平台上实现XMPP通信,Smack是一个非常重要的库,特别是在版本4.1.9时,它提供了丰富的功能,使得开发者能够轻松地构建实时通信应用,如聊天和文件传输。以下将详细介绍XMPP协议以及Smack 4.1.9在Android中...

    最全xmpp开发smack 4.2.2所需jar包

    smack-im-4.2.2.jar smack-tcp-4.2.2.jar smack-extensions-4.2.2.jar smack-core-4.2.2.jar smack-android-extensions-4.2.2.jar jxmpp-jid-0.6.0.jar jxmpp-core-0.6.0.jar jxmpp-util-cache-0.6.0.jar等jar包

    smack库jar

    Smack库是一个强大的开源Java库,专门用于实现XMPP(Extensible Messaging and Presence Protocol)协议。XMPP是一种基于XML的即时通讯协议,广泛应用于聊天应用、协作系统和物联网设备之间的实时通信。Smack库简化...

Global site tag (gtag.js) - Google Analytics