Created
May 4, 2018 03:30
-
-
Save mlcollard/2e413f7411330a7985d5d99c5208c84c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sendChat() { | |
// convert the string message into Data | |
guard let msg = self.messageField.text?.data(using: .utf8) else { | |
print("Error: ", #line) | |
return | |
} | |
// send the converted message | |
try? self.session.send(msg, toPeers: self.session.connectedPeers, with: .unreliable) | |
// update our own chat with the message we just sent | |
self.updateChat(name: "Local", text: self.messageField.text!) | |
// clear out the message field since the message has been sent | |
self.messageField.text = "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment