Skip to content

Instantly share code, notes, and snippets.

@MickaelCruzDB
Created May 3, 2023 13:56
Show Gist options
  • Save MickaelCruzDB/80ff9635e9c7fb1efa49371d3beecd97 to your computer and use it in GitHub Desktop.
Save MickaelCruzDB/80ff9635e9c7fb1efa49371d3beecd97 to your computer and use it in GitHub Desktop.
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