ข้อมูลตลาดหลักทรัพย์

เมื่อทําการเชื่อมต่อระหว่างอุปกรณ์แล้ว คุณจะเริ่มแลกเปลี่ยนข้อมูลได้ ข้อมูลที่แลกเปลี่ยนจะอยู่ในรูปแบบอาร์เรย์ไบต์ง่ายๆ เช่น ข้อความสั้น ไฟล์ต่างๆ เช่น รูปภาพหรือวิดีโอ หรือสตรีม เช่น สตรีมเสียงจากไมโครโฟนของอุปกรณ์

คุณสามารถส่งข้อมูลโดยใช้เมธอดอินสแตนซ์เครื่องมือจัดการการเชื่อมต่อต่อไปนี้

  • send(_:to:)
  • startStream(_:to:)
  • sendResource(at:withName:to:)

คุณสามารถใช้วิธีมอบสิทธิ์ของผู้จัดการการเชื่อมต่อต่อไปนี้เมื่อรับข้อมูล

Swift

extension Example: ConnectionManagerDelegate {
  func connectionManager(
    _ connectionManager: ConnectionManager, didReceive data: Data,
    withID payloadID: PayloadID, from endpointID: EndpointID) {
    // A simple byte payload has been received. This will always include the full data.
  }

  func connectionManager(
    _ connectionManager: ConnectionManager, didReceive stream: InputStream,
    withID payloadID: PayloadID, from endpointID: EndpointID,
    cancellationToken token: CancellationToken) {
    // We have received a readable stream.
  }

  func connectionManager(
    _ connectionManager: ConnectionManager,
    didStartReceivingResourceWithID payloadID: PayloadID,
    from endpointID: EndpointID, at localURL: URL,
    withName name: String, cancellationToken token: CancellationToken) {
    // We have started receiving a file. We will receive a separate transfer update
    // event when complete.
  }

  func connectionManager(
    _ connectionManager: ConnectionManager,
    didReceiveTransferUpdate update: TransferUpdate,
    from endpointID: EndpointID, forPayload payloadID: PayloadID) {
    // A success, failure, cancelation or progress update.
  }
}