【问题标题】:How to send document file, image, video and video in XMPPFrameWork using ejabberd?如何使用 ejabberd 在 XMPPFrameWork 中发送文档文件、图像、视频和视频?
【发布时间】:2021-02-23 09:17:35
【问题描述】:

我尝试使用 ejabberd 在 XMPPFrameWork 中发送文档文件、图像、视频和视频。我尝试使用此代码将图像发送给对手用户。

  func sendImage(_ data:Data){
    let outgoingFileTransfer = XMPPOutgoingFileTransfer(dispatchQueue: .main)
    outgoingFileTransfer.activate(stream)
    outgoingFileTransfer.addDelegate(self, delegateQueue: .main)
    let opponent = XMPPJID(string: modelController.delegate?.userID() ?? .empty)!
    let recipient = XMPPJID(user: opponent.user, domain: opponent.domain, resource: "foo")
    do{
      outgoingFileTransfer.recipientJID = recipient
      outgoingFileTransfer.outgoingData = data
      try outgoingFileTransfer.start()
      try outgoingFileTransfer.start()
      try outgoingFileTransfer.send(data, named: Date().toString(format: .localPhotoSave), toRecipient: recipient, description: "outgoingFileTransfer Description")
    }catch{
      print(error.localizedDescription)
    }
  }
}

但是我遇到了这样的错误

Transfer already in progress.
"xmppOutgoingFileTransfer didFailWithError" Optional(Error Domain=XMPPOutgoingFileTransferErrorDomain Code=503 "<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>, <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" lang="en">User session not found</text>" UserInfo={NSLocalizedDescription=<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>, <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" lang="en">User session not found</text>})

【问题讨论】:

    标签: ios swift ejabberd xmppframework


    【解决方案1】:

    我更喜欢 3. 派对解决方案。例如,您可以使用 Firebase 数据库。

    1. 您可以在 Firebase 存储中上传
    2. Firebase 会给你下载地址
    3. 您可以在附加的任何消息中将此网址发送给其他用户等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-07
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多