Hi,
I'm trying to send text via the Network protocol to a websocket. I have the following code:
func send(data: Data) {
let metaData = NWProtocolWebSocket.Metadata(opcode: .text)
let context = NWConnection.ContentContext (identifier: "context", metadata: [metaData])
self.connection.send(content: data, contentContext: context, isComplete: true, completion: .contentProcessed( { error in
if let error = error {
self.connectionDidFail(error: error)
return
}
print("connection \(self.id) did send")
}))
}
This sends the text to the NWConnection, however it logs an error:
__nw_frame_claim Claiming bytes failed because start (7) is beyond end (0 - 0)
(with 7 being the length of the data).
Is there something I'm doing wrong here? Any ideas?