Latest 0.2.7
Homepage https://github.com/ShengHuaWu/StompClient
License MIT
Platforms ios 9.0, requires ARC
Dependencies Starscream
Authors

Stomp Client

Swift Version
CocoaPods Compatible
Carthage compatible
Platform

This project is a simple STOMP client in Swift,
and we use Starscream as a websocket dependency.

Usage

First thing is to import the Starscream and StompClient frameworks.
Once imported, you’re able to connect to the server. Note that client is probably best as a property, so it doesn’t get deallocated right after being setup.

let url = server_url
client = StompClient(url: url)
client.delegate = self
client.connect()

After you are connected, there are some delegate methods that you need to implement.

Delegate Methods

stompClientDidConnected(client: StompClient) is called when the client connects to the server.

stompClient(client: StompClient, didErrorOccurred error: NSError) is called when error occurs.

stompClient(client: StompClient, didReceivedData data: NSData, fromDestination destination: String) is called when the client receive a message from a subscription destination.

Subscription

You can use subscribe(destination: String, parameters: [String : String]?) method to subscribe a topic, and this method will return a destination id string.
Please pass this string to the second argument when invoking unsubscribe(destination: String, destinationId: String)

Installation

Carthage

Add the following line into your Cartfile,

github "ShengHuaWu/StompClient"

, and then run carthage update --platform ios in your terminal.

CocoaPods

Create a Podfile as following,

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
  pod 'StompClient', '~> 0.2.6'
end

, and then run pod install in your terminal.

Latest podspec

{
    "name": "StompClient",
    "version": "0.2.7",
    "summary": "Simple STOMP client.",
    "description": "This project is a simple STOMP client, and we use Starscream as a websocket dependency.",
    "homepage": "https://github.com/ShengHuaWu/StompClient",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ShengHua Wu": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ShengHuaWu",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/ShengHuaWu/StompClient.git",
        "tag": "0.2.7"
    },
    "source_files": "StompClient/*.swift",
    "requires_arc": true,
    "dependencies": {
        "Starscream": [
            "~> 2.0.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This