Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TradeWithIt/WebSocket
Swift WebSocket client. Works on any platform Linux, Windows, iOS, Android, WASI and more
https://github.com/TradeWithIt/WebSocket
android ios linux macos swift wasi wasm websocket windows
Last synced: 13 days ago
JSON representation
Swift WebSocket client. Works on any platform Linux, Windows, iOS, Android, WASI and more
- Host: GitHub
- URL: https://github.com/TradeWithIt/WebSocket
- Owner: TradeWithIt
- License: mit
- Created: 2024-03-24T00:24:58.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-07-22T09:17:59.000Z (4 months ago)
- Last Synced: 2024-07-22T11:13:05.823Z (4 months ago)
- Topics: android, ios, linux, macos, swift, wasi, wasm, websocket, windows
- Language: Swift
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebSocket
WebSocket client for **Apple** platforms build on top of Foundation `URLSessionWebSocketTask`## Usage
Set auth:
```
import WebSocketlet websocket = WebSocket()
let request = URLRequest(url: URL(string: "wss:my-url")!)try websocket.connect(to: request) { socket in
socket.onText { ws, text in
}
socket.onData { ws, data in
}
socket.onClose { ws in
}
}
```## Installation
### Swift Package Manager
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding a dependency is as easy as adding it to the dependencies value of your Package.swift.
Add the package dependency in your Package.swift:
```
dependencies: [
.package(url: "https://github.com/TradeWithIt/WebSocket", branch: "main")
]
```
Next, in your target, add OpenAPIURLSession to your dependencies:
```
.target(name: "MyTarget", dependencies: [
.product(name: "WebSocket", package: "WebSocket"),
]),
```