0

这就是我尝试使用asmacklib(来自 GtalkSms 项目)和 Ejabberd 服务器通过 XMPP 发送文件的方式:

//Configure provider in onCreate()
 configure(ProviderManager.getInstance());

// Configure function
private void configure(ProviderManager pm){
    pm.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
    pm.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
    pm.addIQProvider("open","http://jabber.org/protocol/ibb", new OpenIQProvider());
    pm.addIQProvider("close","http://jabber.org/protocol/ibb", new CloseIQProvider());
    pm.addExtensionProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
}

// This is how I send file after login to server (I put everything below in a 
function, inside a Thread and call thread.start() at the end of function):

// set the serviceDiscoveryManager
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(xmppConn);
if (sdm == null){
    sdm = new ServiceDiscoveryManager(xmppConn);
}
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");

 // Create the file transfer manager
 FileTransferManager manager = new FileTransferManager(connection);
 FileTransferNegotiator.setServiceEnabled(connection, true);
 OutgoingFileTransfer transfer = manager
                    .createOutgoingFileTransfer(Receiver
                            + "@MyDomain");
 transfer.sendFile(new File(myFilePath), "myDescription");

如果我使用另一个客户端来测试文件传输(http://coccinella.im/),那么我可以在(2 个 coccinella 客户端)之间通过我的 Ejarbberd 服务器聊天并发送文件。如果我在 android 中使用 coccinella 客户端和我的客户端,我可以在他们之间聊天,我可以接收从 coccinella 客户端发送到我的 android 客户端的文件。但是,当我尝试将文件从我的 android 客户端发送到 coccinella 客户端时,transfer.isDone()总是返回true并且transfer.getStatus() == Status.error还返回true.

那么我的安卓客户端怎么了?我使用了错误的库吗?还是我错过了什么?

编辑:这是我从调试器得到的:<iq id="QgJIb-29" to="phuocdh@localhost/Smack" from="phuoctest@localhost/Coccinella@phuocdh-pc" type="error"><error code="404" type="CANCEL"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost></streamhost></query></error></iq>

4

0 回答 0