Android客户端基于XMPP的IM(openfire+asmack)的聊天工具之环境搭建及与服务器建立连接(一)
来源:互联网 发布:nginx 判断请求参数 编辑:程序博客网 时间:2024/05/17 22:04
以下只是个人的入门练习
1、做一番百度,你就了解标题上的名词,赶紧去百度吧。
2、我用openfire作为服务端,就省得自己去搭建。
3、自己去下载Openfire,ASmack吧,网上老多了,下载后安装Openfire(安装配置网上也很多),导入asmack的jar包。
主要文件浏览
/IM/src/com/example/service/XxmpConnection.java
import org.jivesoftware.smack.ConnectionConfiguration;import org.jivesoftware.smack.XMPPConnection;import org.jivesoftware.smack.XMPPException;public class XxmpConnection { private static XMPPConnection con = null; private static void openConnection() { try { // url、端口,也可以设置连接的服务器名字,地址,端口,用户。 ConnectionConfiguration connConfig = new ConnectionConfiguration("192.168.10.74", 5222); // configuration设置// connConfig.setReconnectionAllowed(true);// connConfig.setCompressionEnabled(false);// connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);// connConfig.setSASLAuthenticationEnabled(false); con = new XMPPConnection(connConfig); con.connect(); } catch (XMPPException xe) { xe.printStackTrace(); } } public static XMPPConnection getConnection() { if (con == null) { openConnection(); } return con; } public static void closeConnection() { con.disconnect(); con = null; }}
先说说我注册时遇到的问题
搜了一下,有说设置客户端
configuration设置
connConfig.setReconnectionAllowed(true);
connConfig.setCompressionEnabled(false);
connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
connConfig.setSASLAuthenticationEnabled(false);
有说设置服务端把 服务器设置——>安全设置——>客户端安全连接中的非必须改为自定义
我都试了一下,都没解决我的问题
是我大意了,我的电脑连的wifi服务端昨天写的,昨天和今天的ip不一样,所以改一下ip就好了
但是我还好奇如果我客户端没有给configuration配置会怎样呢,所以我注销了上面的配置
我人品好注册成功
然后我又把服务端自定义改为非必须,注册依旧成功
所以遇到问题多搜搜,解决方法都不一样。
0 0
- Android客户端基于XMPP的IM(openfire+asmack)的聊天工具之环境搭建及与服务器建立连接(一)
- Android客户端基于XMPP的IM(openfire+asmack)的聊天工具之注册(二)
- Android客户端基于XMPP的IM(openfire+asmack)的聊天工具之登录(三)
- Android基于XMPP Smack Openfire开发IM(1)搭建openfire服务器
- Android基于XMPP Smack Openfire开发IM【三】客户端接收服务器发送的消息
- Android基于XMPP Smack Openfire开发IM【三】客户端接收服务器发送的消息
- Android IM之基于Openfire+Smack的聊天服务器的搭建与测试
- 基于Xmpp,Openfire和Asmack的聊天软件的开发(一)
- android基于XMPP SmackOpenfire开发IM(1)搭建openfire服务器
- Android XMPP聊天的实现(asmack+openfire)
- Xmpp协议 OpenFire服务器 Asmack Android客户端 一些Bug的解决方法
- 基于XMPP协议的Android IM研究(asmack)
- xmpp协议学习之搭建openfire服务器以及asmack的使用!
- XMPP(二)-基于asmack+openfire的安卓客户端(仿QQ)的介绍以及个人心得
- XMPP(二)-基于asmack+openfire的安卓客户端(仿QQ)的介绍以及个人心得
- XMPP-Android基于openfire+asmack
- 基于XMPP的IM(openfire+spark)Spark 插件开发
- Iphone 上开发IM基于XMPP协议的LBS 程序(1),联通openfire服务器
- [dp] hdu 4472 Count
- Fragment的startActivityForResult详细解决方案
- jqgrid学习过程问题记录
- C/C++学习:函数指针
- v$sql和v$sqlarea
- Android客户端基于XMPP的IM(openfire+asmack)的聊天工具之环境搭建及与服务器建立连接(一)
- Fragment与FragmentActivity间的数据通讯详细解决方案
- How to SetUp The Receiving Transaction Manager
- 干货|78张PPT读懂2014互联网跨界趋势
- system.in close()方法和skip()
- 2014年10月30日学习笔记
- ubuntu install svn with apache dav_svn
- 网络编程I/O函数介绍
- POJ 2724 Purifying Machine(最大独立集)