11# StompClientLib
2+
23<p align =" center " >
34<img width =" 200 " height =" 200 " src =" https://github.com/WrathChaos/StompClientLib/blob/master/Screenshots/socket.png " >
45</p >
56
6-
77<p align =" center " >
88<a href =" https://github.com/WrathChaos/StompClientLib " >
99<img src="https://img.shields.io/cocoapods/l/StompClientLib.svg "
@@ -19,7 +19,6 @@ alt="Cocoapods">
1919</a >
2020</p >
2121
22-
2322<p align =" center " >
2423<a href =" https://github.com/WrathChaos/MJPEGStreamLib " >
2524<img src="https://img.shields.io/badge/Swift-5.0-red.svg "
@@ -39,8 +38,6 @@ alt="Issues">
3938</a >
4039</p >
4140
42-
43-
4441## Introduction
4542
4643StompClientLib is a stomp client in Swift. It uses Facebook's [ SocketRocket ] ( https://github.com/facebook/SocketRocket ) as a websocket dependency. SocketRocket is written in Objective-C but StompClientLib's STOMP part is written in Swift and its usage is Swift. You can use this library in your Swift 5+, 4+ and 3+ projects.
@@ -52,6 +49,7 @@ This is original a fork from [AKStompClient](https://github.com/alibasta/AKStomp
5249To run the example project, clone the repo, and run ` pod install ` from the Example directory first.
5350
5451## Requirements
52+
5553- iOS 8.0+
5654- XCode 8.1, 8.2, 8.3
5755- XCode 9.0+
@@ -60,28 +58,30 @@ To run the example project, clone the repo, and run `pod install` from the Examp
6058- Swift 3.0, 3.1, 3.2
6159- ** Swift 4.0, Swift 4.1, Swift 4.2, Swift 5.0**
6260
63-
6461## Installation
6562
6663StompClientLib is available through [ CocoaPods] ( http://cocoapods.org ) . To install
6764it, simply add the following line to your Podfile:
6865
6966#### Cocoapods
67+
7068``` ruby
7169pod " StompClientLib"
7270```
7371
7472#### Carthage
73+
7574``` ruby
7675github " WrathChaos/StompClientLib"
7776```
7877
7978## Usage
79+
8080``` ruby
8181import StompClientLib
8282```
8383
84- Once imported, you can open a connection to your WebSocket server.
84+ Once imported, you can open a connection to your WebSocket server.
8585
8686``` ruby
8787var socketClient = StompClientLib ()
@@ -94,6 +94,7 @@ After you are connected, there are some delegate methods that you need to implem
9494# StompClientLibDelegate
9595
9696## stompClientDidConnect
97+
9798``` ruby
9899func stompClientDidConnect(client: StompClientLib !) {
99100print (" Socket is connected" )
@@ -104,15 +105,17 @@ socketClient.subscribe(destination: topic)
104105```
105106
106107## stompClientDidDisconnect
108+
107109``` ruby
108110func stompClientDidDisconnect(client: StompClientLib !) {
109111print (" Socket is Disconnected" )
110112}
111113```
112114
113- ## didReceiveMessageWithJSONBody ( Message Received via STOMP )
115+ ## didReceiveMessageWithJSONBody ( Message Received via STOMP )
114116
115117Your json message will be converted to JSON Body as AnyObject and you will receive your message in this function
118+
116119``` ruby
117120func stompClient(client: StompClientLib !, didReceiveMessageWithJSONBody jsonBody: AnyObject ?, akaStringBody stringBody: String ?, withHeader header: [String : String ]?, withDestination destination: String ) {
118121print (" Destination : \( destination)" )
@@ -121,20 +124,21 @@ print("String Body : \(stringBody ?? "nil")")
121124}
122125```
123126
124- ## didReceiveMessageWithJSONBody ( Message Received via STOMP as String )
127+ ## didReceiveMessageWithJSONBody ( Message Received via STOMP as String )
125128
126129Your json message will be converted to JSON Body as AnyObject and you will receive your message in this function
130+
127131``` ruby
128132func stompClientJSONBody(client: StompClientLib !, didReceiveMessageWithJSONBody jsonBody: String ?, withHeader header: [String : String ]?, withDestination destination: String ) {
129133print (" DESTIONATION : \( destination)" )
130134print (" String JSON BODY : \( String(describing: jsonBody))" )
131135}
132136```
133137
138+ ## serverDidSendReceipt
134139
135- ## serverDidSendReceipt
140+ If you will use STOMP for in-app purchase, you might need to use this function to get receipt
136141
137- If you will use STOMP for in-app purchase, you might need to use this function to get receipt
138142``` ruby
139143func serverDidSendReceipt(client: StompClientLib !, withReceiptId receiptId: String ) {
140144print (" Receipt : \( receiptId)" )
@@ -153,26 +157,27 @@ print("Error Send : \(String(describing: message))")
153157
154158## serverDidSendPing
155159
156- If you need to control your server's ping, here is your part
160+ If you need to control your server's ping, here is your part
157161
158162``` ruby
159163func serverDidSendPing() {
160164print (" Server ping" )
161165}
162166```
163167
164-
165168## How to subscribe and unsubscribe
166169
167- There are functions for subscribing and unsubscribing.
168- Note : You should handle your subscribe and unsubscibe methods !
169- Suggestion : Subscribe to your topic in "stompClientDidConnect" function and unsubcribe to your topic in stompClientWillDisconnect method.
170+ There are functions for subscribing and unsubscribing.
171+ Note : You should handle your subscribe and unsubscibe methods !
172+ Suggestion : Subscribe to your topic in "stompClientDidConnect" function and unsubcribe to your topic in stompClientWillDisconnect method.
170173
171174## Subscribe
175+
172176``` ruby
173177socketClient.subscribe(destination: topic)
174178// Note : topic needs to be a String object
175179```
180+
176181## Unsubscribe
177182
178183``` ruby
@@ -185,7 +190,7 @@ Important : You have to send your destination for both subscribe or unsubscribe!
185190
186191``` ruby
187192let destination = " /topic/your_topic"
188- let ack = destination
193+ let ack = destination
189194let id = destination
190195let header = [" destination" : destination, " ack" : ack, " id" : id]
191196
@@ -197,7 +202,8 @@ socketClient?.unsubscribe(destination: subsId)
197202```
198203
199204## Auto Reconnect with a given time
200- You can use this feature if you need to auto reconnect with a spesific time or it will just try to reconnect every second.
205+
206+ You can use this feature if you need to auto reconnect with a spesific time or it will just try to reconnect every second.
201207
202208``` ruby
203209// Reconnect after 4 sec
@@ -211,7 +217,6 @@ socketClient.reconnect(request: NSURLRequest(url: url as URL) , delegate: self a
211217socketClient.autoDisconnect(time: 3 )
212218```
213219
214-
215220## Future Enhancements
216221
217222- [x] <del >Complete a working Example<del >
@@ -224,13 +229,24 @@ socketClient.autoDisconnect(time: 3)
224229
225230# Change Log
226231
227- [ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.5...HEAD )
232+ ## [ 1.3.6] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.6 ) (2019-08-06)
233+
234+ [ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.5...1.3.6 )
228235
229236** Fixed bugs:**
230237
231238- v1.3.4 replaced my custom header in open socket? [ \# 58] ( https://github.com/WrathChaos/StompClientLib/issues/58 )
232239
240+ ** Closed issues:**
241+
242+ - Json error: The data couldn’t be read because it isn’t in the correct format. [ \# 60] ( https://github.com/WrathChaos/StompClientLib/issues/60 )
243+
244+ ** Merged pull requests:**
245+
246+ - Fixed ACK id header and added new ACK type [ \# 62] ( https://github.com/WrathChaos/StompClientLib/pull/62 ) ([ rodmytro] ( https://github.com/rodmytro ) )
247+
233248## [ 1.3.5] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.5 ) (2019-07-25)
249+
234250[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.4...1.3.5 )
235251
236252** Fixed bugs:**
@@ -247,9 +263,11 @@ socketClient.autoDisconnect(time: 3)
247263- \# 58 fix open socket with custom header issue [ \# 59] ( https://github.com/WrathChaos/StompClientLib/pull/59 ) ([ marain87] ( https://github.com/marain87 ) )
248264
249265## [ 1.3.4] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.4 ) (2019-07-19)
266+
250267[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.3...1.3.4 )
251268
252269## [ 1.3.3] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.3 ) (2019-07-18)
270+
253271[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.2...1.3.3 )
254272
255273** Closed issues:**
@@ -262,6 +280,7 @@ socketClient.autoDisconnect(time: 3)
262280- String body parameter and ':'-in-header-value fix [ \# 56] ( https://github.com/WrathChaos/StompClientLib/pull/56 ) ([ Erhannis] ( https://github.com/Erhannis ) )
263281
264282## [ 1.3.2] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.2 ) (2019-07-10)
283+
265284[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.1...1.3.2 )
266285
267286** Implemented enhancements:**
@@ -273,6 +292,7 @@ socketClient.autoDisconnect(time: 3)
273292- Added 'akaStringBody' parameter to stompClient didReceiveMessage... [ \# 49] ( https://github.com/WrathChaos/StompClientLib/pull/49 ) ([ Erhannis] ( https://github.com/Erhannis ) )
274293
275294## [ 1.3.1] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.1 ) (2019-06-14)
295+
276296[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.3.0...1.3.1 )
277297
278298** Closed issues:**
@@ -287,6 +307,7 @@ socketClient.autoDisconnect(time: 3)
287307- Delegate StompClientDidConnect not called after connect-\> disconnect-\> connect [ \# 15] ( https://github.com/WrathChaos/StompClientLib/issues/15 )
288308
289309## [ 1.3.0] ( https://github.com/WrathChaos/StompClientLib/tree/1.3.0 ) (2019-04-30)
310+
290311[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.7...1.3.0 )
291312
292313** Implemented enhancements:**
@@ -298,12 +319,14 @@ socketClient.autoDisconnect(time: 3)
298319- Should add Carthage [ \# 33] ( https://github.com/WrathChaos/StompClientLib/issues/33 )
299320- Invalid Sec-WebSocket-Accept response [ \# 32] ( https://github.com/WrathChaos/StompClientLib/issues/32 )
300321- Socket is disconnected with 1007 code as soon as it connected [ \# 31] ( https://github.com/WrathChaos/StompClientLib/issues/31 )
301- - enable Assert \( self.readyState != SR \_ CONNECTING \) [ \# 24] ( https://github.com/WrathChaos/StompClientLib/issues/24 )
322+ - enable Assert \( self.readyState != SR_CONNECTING \) [ \# 24] ( https://github.com/WrathChaos/StompClientLib/issues/24 )
302323
303324## [ 1.2.7] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.7 ) (2018-10-23)
325+
304326[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.6...1.2.7 )
305327
306328## [ 1.2.6] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.6 ) (2018-10-23)
329+
307330[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.5...1.2.6 )
308331
309332** Fixed bugs:**
@@ -315,6 +338,7 @@ socketClient.autoDisconnect(time: 3)
315338- Auto disconnects [ \# 11] ( https://github.com/WrathChaos/StompClientLib/issues/11 )
316339
317340## [ 1.2.5] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.5 ) (2018-10-22)
341+
318342[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.4...1.2.5 )
319343
320344** Closed issues:**
@@ -325,13 +349,15 @@ socketClient.autoDisconnect(time: 3)
325349- Getting error when framwork is installed in Objective c project [ \# 9] ( https://github.com/WrathChaos/StompClientLib/issues/9 )
326350
327351## [ 1.2.4] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.4 ) (2018-10-17)
352+
328353[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.3...1.2.4 )
329354
330355** Closed issues:**
331356
332357- didCloseWithCode 1000, reason: nil [ \# 21] ( https://github.com/WrathChaos/StompClientLib/issues/21 )
333358
334359## [ 1.2.3] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.3 ) (2018-10-17)
360+
335361[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.2...1.2.3 )
336362
337363** Implemented enhancements:**
@@ -352,12 +378,15 @@ socketClient.autoDisconnect(time: 3)
352378- Unable to find a specification for 'StompClientLib' [ \# 8] ( https://github.com/WrathChaos/StompClientLib/issues/8 )
353379
354380## [ 1.2.2] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.2 ) (2017-11-03)
381+
355382[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.1...1.2.2 )
356383
357384## [ 1.2.1] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.1 ) (2017-10-31)
385+
358386[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.2.0...1.2.1 )
359387
360388## [ 1.2.0] ( https://github.com/WrathChaos/StompClientLib/tree/1.2.0 ) (2017-10-29)
389+
361390[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.1.7...1.2.0 )
362391
363392** Closed issues:**
@@ -367,33 +396,39 @@ socketClient.autoDisconnect(time: 3)
367396- Error when calling delegate [ \# 1] ( https://github.com/WrathChaos/StompClientLib/issues/1 )
368397
369398## [ 1.1.7] ( https://github.com/WrathChaos/StompClientLib/tree/1.1.7 ) (2017-10-02)
399+
370400[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/1.1.6...1.1.7 )
371401
372402## [ 1.1.6] ( https://github.com/WrathChaos/StompClientLib/tree/1.1.6 ) (2017-08-08)
403+
373404[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.5...1.1.6 )
374405
375406## [ 0.1.5] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.5 ) (2017-07-10)
407+
376408[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.4...0.1.5 )
377409
378410## [ 0.1.4] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.4 ) (2017-07-10)
411+
379412[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.3...0.1.4 )
380413
381414## [ 0.1.3] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.3 ) (2017-07-10)
415+
382416[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.2...0.1.3 )
383417
384418## [ 0.1.2] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.2 ) (2017-07-08)
419+
385420[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.1...0.1.2 )
386421
387422## [ 0.1.1] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.1 ) (2017-07-08)
423+
388424[ Full Changelog] ( https://github.com/WrathChaos/StompClientLib/compare/0.1.0...0.1.1 )
389425
390426## [ 0.1.0] ( https://github.com/WrathChaos/StompClientLib/tree/0.1.0 ) (2017-07-08)
391427
392-
428+ \* _ This Change Log was automatically generated by [ github_changelog_generator ] ( https://github.com/skywinder/Github-Changelog-Generator ) _
393429
394430** [ CHANGELOG.md] ( https://github.com/WrathChaos/StompClientLib/blob/master/CHANGELOG.md ) **
395431
396-
397432## Author
398433
399434FreakyCoder, kurayogun@gmail.com
0 commit comments