Skip to content

megakit-pro/OctobusClient

Repository files navigation

README for OctobusClient

Introduction

OctobusClient is a Swift package that facilitates WebSocket communications, tailored specifically for the Octobus ecosystem. With the added capability of Gzip compression and robust event handling, it's designed to be a powerful and reliable WebSocket client.

Features

  • Establish WebSocket connections with ease.
  • Send and receive Gzipped messages.
  • Comprehensive logging for effective debugging.
  • Built upon the powerful Starscream library.

Installation

Swift Package Manager

To integrate OctobusClient into your Xcode project using Swift Package Manager, add it to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/megakit-pro/OctobusClient.git", from: "1.0.0")
]

Replace 1.0.0 with the latest version if necessary.

Usage

Creating a Client Instance

let client = OctobusClient()
client.delegate = self  // Make sure to implement the OctobusClientDelegate protocol

Connecting to a Server

let token = "YOUR_ACCESS_TOKEN"
client.connect(to: "ws://your.server.url/path", with: token)

Sending Messages

To send messages:

let message = Message(/* Your message content here */)
client.send(message: message)

Note: Ensure that your message conforms to the Message protocol expected by the send(message:) method.

Delegate Methods

Implement the OctobusClientDelegate protocol to handle various events:

  • setConnected(_:): Called when the connection status changes.
  • handleIcommingMessage(data:): Handles incoming messages.
  • setError(_:): Called when an error occurs.

Dependencies

  • GzipSwift: For Gzip compression and decompression.
  • Starscream: A reliable WebSocket library for Swift.

Contributing

We welcome contributions! Please see the CONTRIBUTING.md file for details.

License

Please refer to the LICENSE file for details on the license.

About

Octobus Client Swift package

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages