@@ -39,6 +39,7 @@ public protocol RTMWebSocket {
3939public protocol RTMAdapter : class {
4040 func initialSetup( json: [ String : Any ] , instance: SKRTMAPI )
4141 func notificationForEvent( _ event: Event , type: EventType , instance: SKRTMAPI )
42+ func connectionClosed( with error: Error , instance: SKRTMAPI )
4243}
4344
4445public protocol RTMDelegate : class {
@@ -53,7 +54,7 @@ public final class SKRTMAPI: RTMDelegate {
5354 public var adapter : RTMAdapter ?
5455 public var token = " xoxp-SLACK_AUTH_TOKEN "
5556 internal var options : RTMOptions
56- var connected = false
57+ public private ( set ) var connected = false
5758
5859 var ping : Double ?
5960 var pong : Double ?
@@ -86,7 +87,7 @@ public final class SKRTMAPI: RTMDelegate {
8687 success: { ( response) in
8788 self . connectWithResponse ( response)
8889 } , failure: { ( error) in
89- print ( error)
90+ self . adapter ? . connectionClosed ( with : error, instance : self )
9091 }
9192 )
9293 } else {
@@ -97,7 +98,7 @@ public final class SKRTMAPI: RTMDelegate {
9798 success: { ( response) in
9899 self . connectWithResponse ( response)
99100 } , failure: { ( error) in
100- print ( error)
101+ self . adapter ? . connectionClosed ( with : error, instance : self )
101102 }
102103 )
103104 }
@@ -213,6 +214,8 @@ public final class SKRTMAPI: RTMDelegate {
213214 connected = false
214215 if options. reconnect {
215216 connect ( )
217+ } else {
218+ adapter? . connectionClosed ( with: SlackError . rtmConnectionError, instance: self )
216219 }
217220 }
218221
0 commit comments