
Starscream is a conforming WebSocket (RFC 6455) library in Swift.
Features
- Conforms to all of the base Autobahn test suite.
- Nonblocking. Everything happens in the background, thanks to GCD.
- TLS/WSS support.
- Compression Extensions support (RFC 7692)
Import the framework
First thing is to import the framework. See the Installation instructions on how to add the framework to your project.
import Starscream
Connect to the WebSocket Server
Once imported, you can open a connection to your WebSocket server. Note that socket is probably best as a property, so it doesn't get deallocated right after being setup.
var request = URLRequest(url: URL(string: "http://localhost:8080")!)
request.timeoutInterval = 5
socket = WebSocket(request: request)
socket.delegate = self
socket.connect()