/** * 发送文件 * @param con 用户连接对象 * @param fullJID 用户jid 形式如:demo@serviceName/Spark 2.6.3 * @param filePath 文件路径 */ public boolean sendFiles(XMPPConnection con,String fullJID,String filePath){ File files=new File(filePath); FileTransferManager fileManager=new FileTransferManager(con); OutgoingFileTransfer sendfile=fileManager.createOutgoingFileTransfer(fullJID); try { sendfile.sendFile(files, "Sending file"); return true; } catch (XMPPException e) { e.printStackTrace(); return false; } } /** * 接收文件 * @param con 用户连接对象 * @param filePath 文件路径 */ public void receiveFiles(XMPPConnection con,final String filePath){ FileTransferManager fileManager=new FileTransferManager(con); fileManager.addFileTransferListener(new FileTransferListener() { @Override public void fileTransferRequest(FileTransferRequest prequest) { //System.out.println("The file received from: " + prequest.getRequestor()); System.out.println("filePath:"+filePath+"||FileName:"+prequest.getFileName()); file = new File(filePath +"\\" +prequest.getFileName()); request = prequest; IncomingFileTransfer infiletransfer =request.accept(); try { infiletransfer.recieveFile(file); System.out.println("接收成功!"); } catch (XMPPException e) { e.printStackTrace(); } } }); }
相关推荐
smark接收文件实例,网上的东东太多不能用了,只能一点点去琢磨做出来的
一个简单的demo用于登陆Openfire 发送消息,接收消息,发送表情等功能
smack发送消息 smack相关的两个包
SMACK文件传输的介绍及代码,官网源文件
花了两天时间,成功解决xmpp协议smack间传文件的问题。保证能正常传输。
openfire4.2.1 + smack4.2.2即时通信工具开发(android端登录、发送消息、接收消息),请参见我的博客http://blog.csdn.net/wangearn/article/details/79096347
网友例子很多,大多都不能用,只有自己动手了..呵呵
使用SMACK虚拟文件系统和CIPSO进行网络安全控制
smack jar 文件 Smack是一个开源,易于使用的XMPP(jabber)客户端类库。 Smack API, 是一个 Java 的XMPP Client Library,也是由Jive Software开发。 优点:编程简单。 缺点:API并非为大量并发用户设计,每个客户要1个...
关于Smack编程库,前面我们提到,它是面向Java端的api,主要在PC上使用,利用它我们可以向openfire服务器注册用户,发送消息,并且可以通过监听器获得此用户的应答消息,以及构建聊天室,分组,个人通讯录等等。
Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档
android openfire xmpp smack即时通讯,包括:聊天发生文字,表情,图片,语音。添加删除好友,消息提醒,群聊,邀请好友进入房间,聊天记录保存等等。界面美观。最后说明:此demo是在网上一个叫EIM企信通的demo基础...
XMPP+Openfire4.5.1+Smack4.3.4+MySql,支持手机对手机,手机对PC(Spark)的消息收发
smack源码
android项目中打印xmpp协议(收发的报文)到日志文件,只需将代码中使用的Log.debug替换为你自己输入到日志文件的代码即可,详情见https://blog.csdn.net/w690333243/article/details/79963639
基于Openfire消息服务器应用Smack发送即时消息jar包,使用说明见http://blog.csdn.net/duanml61/article/details/8612845
Smack中文API文档
这个是Smack API的中文版,详细介绍了smack原理,并且有几个小例子在里面
smack用于android移动端的开发,可以结合openfire使用,进行im通信
Smack主要是xmpp协议的实现,提供了一套很好的api,所以下面操作xmpp都是通过使用Smack的api来实现,从4.1.0开始,它就支持Android了,所以我们直接使用Smack即可,当然在这不支持之前是使用Asmack这个包的,里面...