Created
May 3, 2023 13:56
-
-
Save MickaelCruzDB/80ff9635e9c7fb1efa49371d3beecd97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 routes(_ app: Application) throws { | |
app.webSocket("commands") { request, ws in | |
ws.send("Connection OK") | |
ws.onText { ws, string in | |
ws.send(string + " : OK") | |
} | |
ws.onClose.whenComplete { result in | |
switch result { | |
case .success(): | |
print("Closed") | |
case .failure(let error): | |
print("Failed to close connection \(error)") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment