<commit_before>## Stomp Client [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
This project is a simple STOMP client,
and we use [_Starscream_](https://github.com/daltoniam/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
    let socket = WebSocket(url: url)
    client = StompClient(socket: socket)
    client = self
    client.connect()

After you are connected, there are some delegate methods that we 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)` is called when the client receive a message from the server.

#### Subscription
You can use `subscribe(destination: String, parameters: ParametersConvertible?)` method to subscribe a topic.

It's possible to pass parameters in subscription. Just create a `struct` for your parameters and let it conform `ParametersConvertible` protocol.

    struct MyParameters: ParametersConvertible {
      let title: String
      let fields: [String]

      func toJSON -> AnyObject {
        return ["title": title, "fields": fields]
      }
    }

### Carthage Install
Add the following line into your _Cartfile_,

      github "ShengHuaWu/StompClient"

and run `carthage update --platform ios` in your terminal.<commit_msg>Modify README file.<commit_after>## Stomp Client [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
This project is a simple STOMP client,
and we use [_Starscream_](https://github.com/daltoniam/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
    let socket = WebSocket(url: url)
    client = StompClient(socket: socket)
    client = self
    client.connect()

After you are connected, there are some delegate methods that we 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)` is called when the client receive a message from the server.

#### Subscription
You can use `subscribe(destination: String, parameters: [String : String]?)` method to subscribe a topic.

### Carthage Install
Add the following line into your _Cartfile_,

      github "ShengHuaWu/StompClient"

and run `carthage update --platform ios` in your terminal.
{'fraction_non_alphanumeric': 0.08626097867001255, 'fraction_numerical': 0.0018820577164366374, 'mean_word_length': 4.694642857142857, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '36249', 'n_tokens_mistral': 930, 'n_tokens_neox': 894, 'n_words': 353}