- import java.util.Collection;
- import org.jivesoftware.smack.packet.Message;
- import org.jivesoftware.smack.packet.Presence;
- public class SimpleClient {
- /** Server name */
- public static final String SERVER_NAME = "localhost";
- /** Server port */
- public static final int SERVER_PORT = 5222; // as you can see in Admin
- // Console properties
- /** Client name - for login */
- private final String clientName;
- /** Client password - for login*/
- private final String clientPassword;
- /** Client color - for writing in color */
- private final String clientColor;
- /** Chat friend */
- private final String friendName;
- /**
- * Constrcuts a new SimpleClient
- * @param clientName0 -
- * @param clientPassword0 -
- * @param clientColor0 -
- * @param friendName0 -
- */
- public SimpleClient(String clientName0, String clientPassword0, String clientColor0, String friendName0) {
- super();
- this.clientName = clientName0;
- this.clientPassword = clientPassword0;
- this.clientColor = clientColor0;
- this.friendName = friendName0;
- }
- /**
- * Main process.
- */
- public void run() {
- try {
- this.runImpl();
- } catch (XMPPException e) {
- System.err.println("Exception: " + e);
- }
- }
- private void runImpl() throws XMPPException {
- XMPPConnection.DEBUG_ENABLED = true;
- /*
- * Configuration
- */
- final ConnectionConfiguration config = new ConnectionConfiguration(
- SimpleClient.SERVER_NAME, SimpleClient.SERVER_PORT);
- config
- .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
- config.setCompressionEnabled(false);
- /*
- * Open Connection
- */
- final XMPPConnection connection = new XMPPConnection(config);
- connection.connect();
- connection.login(this.clientName, this.clientPassword);
- /*
- * Chat
- */
- final MessageListener messageListner = new SimpleMessageListner();
- final Chat chat = connection.getChatManager().createChat(this.friendName, messageListner);
- final java.util.Date date = new java.util.Date(System.currentTimeMillis());
- final String msgSent = " [sent by " + this.clientName + ", at " + date.toString() + "]";
- final Message newMessage = new Message();
- newMessage.setBody("Howdy (colored)!" + msgSent);
- newMessage.setProperty("favoriteColor", this.clientColor);
- chat.sendMessage(newMessage);
- chat.sendMessage("Howdy!" + msgSent);
- /*
- * Roster
- */
- final Roster roster = connection.getRoster();
- // this is already the default Mode but added just for the example
- Roster
- .setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
- roster.createEntry(this.friendName, "", null);
- this.presenceStatus(roster, "unknown@someone");
- this.presenceStatus(roster, this.friendName);
- final Collection<RosterEntry> entries = roster.getEntries();
- for (RosterEntry entry : entries) {
- System.out.println("RosterEntry " + entry);
- }
- final RosterListener rosterListener = new SimpleRosterListner();
- roster.addRosterListener(rosterListener);
- /*
- * End connection
- */
- connection.disconnect();
- }
- private void presenceStatus(final Roster roster, String user) {
- final Presence presence = roster.getPresence(user);
- final String response = presence == null ? "Not around" : presence.getStatus();
- System.out.println("Presence of '" + user + "': " + response);
- }
- /**
- *
- * @author some
- *
- */
- private class SimpleMessageListner implements MessageListener {
- public void processMessage(Chat chat, Message message) {
- System.out.println("Received message: "
- + message.getBody());
- }
- }
- /**
- *
- * @author some
- *
- */
- private class SimpleRosterListner implements RosterListener {
- // Ignored events
- public void entriesAdded(Collection<String> addresses) {
- }
- public void entriesDeleted(Collection<String> addresses) {
- }
- public void entriesUpdated(Collection<String> addresses) {
- }
- public void presenceChanged(Presence presence) {
- System.out.println("Presence changed: "
- + presence.getFrom() + " " + presence);
- }
- }
- }
- 浏览: 931916 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (423)
- mysql (37)
- hibernate (3)
- struts (9)
- spring (33)
- dom4j (2)
- junit (0)
- exception (1)
- 随笔杂谈 (12)
- google app engine (1)
- XMPP (1)
- OAuth安全授权 (1)
- 版本控制 (8)
- 心情感悟 (0)
- core java (19)
- log4j (7)
- jquery (12)
- javascript (10)
- 网站性能优化及工具 (11)
- 服务器架设配置等 (38)
- EXT (4)
- 正则表达式 (5)
- 日志统计分析 (2)
- htmlparse (4)
- httpclient (5)
- java随笔 (5)
- dhtmlxtree (1)
- freemarke (5)
- memcached (6)
- javamail (5)
- Linux命令 (10)
- 应用监控cpu web jdbc等 (4)
- jmagick (9)
- 第三方缓存策略 (9)
- ORM (2)
- hadoop (2)
- 大数据量处理 (8)
- 经典 (1)
- 权限设计 (1)
- andriod (1)
- mybatis (12)
- redis (24)
- 数据结构_算法 (5)
- 分布式系统 (1)
- php (1)
- 网络编程 (3)
- 服务器部署 (3)
- ios (2)
- IM (23)
- mina (1)
- 视讯和语音 (1)
- 代码生成 (1)
- 架构 (4)
- 建模工具 (1)
- oracle (4)
- solr (10)
- 构建工具 (7)
- html5 (1)
- nginx (5)
- css (1)
- 大数据-分布式 (2)
- 设计模式 (2)
- mq (2)
- jvm调优 (8)
- 并发编程 (2)
- 搜索引擎 (1)
- UML (2)
最新评论
-
天使建站:
jquery获取网页里多选框checkbox选中项的值的方法及 ...
JS jQuery分别获取选中的复选框值 -
abao1:
发现一个小问题 sortAndSave方法中的for循环 第二 ...
完整java实现外部排序 -
西巴拉古呀那:
Kafka分布式消息系统实战(与JavaScalaHadoop ...
消息系统kafka介绍 -
kafodaote:
Kafka分布式消息系统实战(与JavaScalaHadoop ...
消息系统kafka介绍 -
成大大的:
Kafka分布式消息系统实 ...
消息系统kafka介绍
发表评论
-
使用Lucene-Spatial实现集成地理位置的全文检索
2013-08-09 09:11 1135Lucene通过Spatial包提供了对基于地理位置的 ... -
Mongodb 地理位置索引
2013-08-09 08:58 3204Geospatial Indexing Mong ... -
基于Solr的空间搜索(1)
2013-08-08 19:07 1079http://ju.outofmemory.cn/entry ... -
基于Solr的空间搜索(3)
2013-08-08 19:00 951http://ju.outofmemory.cn/entry ... -
将 openfire 源码作为java项目导入eclipse调试
2013-07-01 22:02 1358http://nodex.iteye.com/blog/11 ... -
XMPP 之Openfire的用户数据库整合
2013-06-29 16:35 1179openfire\documentation下的文档有比较详 ... -
Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置
2013-06-29 14:37 1167http://blog.csdn.net/ares1201/ ... -
openfire文件传输
2013-06-29 13:22 1536http://linyu19872008.iteye.com ... -
Tsung负载测试Tigase
2013-06-29 13:06 1928http://linyu19872008.iteye.com ... -
xmpp通信
2013-06-26 21:27 848现在你就可以通过这个web客户端与spark客户端进行好友 ... -
实现手机扫描二维码页面登录,类似web微信-第四篇,服务器端
2013-06-26 17:14 1947http://blog.csdn.net/otangba/a ... -
开发openfire的内部组件
2013-06-26 17:13 1785http://blog.csdn.net/otangba/a ... -
IM实现联系人及联系人分组的数据库设计
2013-06-22 15:30 1969openfire中通过ofgroup/ofgro ... -
【openfire插件开发】数据库处理部分(openfire数据库模式)
2013-06-22 15:12 1230我们都知道,openfire的二次开发一般都是以插件形式组织 ... -
Openfire 用户离线、断线 及心跳检测
2013-06-21 13:12 2088客户端登出分为正常离 ... -
openfire 整合现有数据库
2013-06-21 13:10 1321http://blog.csdn.net/heyi1214/ ... -
openfire客户端文件传输学习笔记(一)
2013-07-02 11:36 1494openfire客户端文件传输学习笔记(一) 项目中需要 ... -
本地部署并运行Openfire和错误处理
2013-06-12 21:51 1668http://xiao9.iteye.com/blog/11 ... -
Openfire 性能优化
2013-06-12 21:43 1699http://blog.csdn.net/smm112307 ... -
Openfire源码研究
2013-06-12 17:23 1878Openfire源码研究 Openfire源码目录结构 ...
相关推荐
通过http方式,向openfire客户端发信息(非XMPP协议) http://blog.csdn.net/hzaccp3/article/details/19964655
openfire是xmpp协议的实现,以其及时性和稳定性被倍受青睐,在此贡献出来Android客户端,希望与大家共同探讨。 文章地址:http://blog.csdn.net/sky_monkey/article/details/9495571
openfire Java客户端开发文档详解
聊天软件的客户端,服务器基于openFire,xmpp协议,已实现添加,删除好友,私聊,群聊,可以发送文本,表情,图片,语音.界面使用Fragment与ViewPager技术.
功能实现了基本聊天功能外还有离线消息、查看历史聊天记录、消息提醒等,代码结构层次也很清晰,很值得下载看看
jitsi 基于 openfire 的 视频通话 客户端
基于xmpp协议的openfire android客户端,登录,接受消息
首先需要搭建openfire服务器,然后在com.qq.util包中,Const类,修改XMPP_HOST内容。
openfire Im android 客户端 可以直接运行
xmppClient 基于openfire和smack的安卓客户端 todo 增加文档 优化tablayout图标 增加通知 完成发现,我界面 运行截图 运行截图
openfire android客户端,Openfire 是实时的基于WEB的即时消息传输平台,通过此客户端可实现类似微信、米聊等的即时聊天功能
openfire集成第三方系统配置,数据库配置方法
android Openfire的测试客户端程序,只是个测试程序
基于Smack3.0.4+ Openfire3.10.2开发之Android 客户端之三(用户登入、用户注册与XMPP 服务器交互)。
利用smack对xmpp协议的封装,对openfire服务器进行高效简单的连接
基于openfire的即时通讯客户端实例
spark 汉化包,一个关于openfire的客户端软件的汉化包
扩展openfire的服务端代码。实现了图片,语音,视频发送,可创建群组。发表签名等功能。可作为android和ios聊天的服务端。
android openfire xmpp smack即时通讯,包括:聊天发生文字,表情,图片添加删除好友,消息提醒,群聊,邀请好友进入房间,欢迎大家下载
基于Smack3.0.4+ Openfire3.10.2开发之Android 客户端之二(注册界面设计与实现)相关源代码