mirror of https://github.com/vapor/docs.git
749 B
749 B
WebSocket Client
WebSocket clients work the same on the client side as the server side.
Connecting a WebSocket client
WebSockets require an URI to connect to and a Worker to run on.
!!! warning Vapor does not retain the WebSocket. It is the responsibility of the user to keep the WebSocket active by means of strong references and pings.
let worker: Worker = ...
let futureWebSocket: Future<WebSocket> = try WebSocket.connect(to: "ws://localhost/path", worker: worker)
Using websockets
WebSockets are interacted with using binary streams or text streams.
All other information about websockets is defined here.