@@ -90,16 +90,12 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
9090 }
9191 }
9292
93- public func openSocketWithURLRequest( request: NSURLRequest , delegate: StompClientLibDelegate ) {
93+ public func openSocketWithURLRequest( request: NSURLRequest , delegate: StompClientLibDelegate , connectionHeaders: [ String : String ] ? = nil ) {
94+ self . connectionHeaders = connectionHeaders
9495 self . delegate = delegate
9596 self . urlRequest = request
9697 // Opening the socket
9798 openSocket ( )
98- }
99-
100- public func openSocketWithURLRequest( request: NSURLRequest , delegate: StompClientLibDelegate , connectionHeaders: [ String : String ] ? ) {
101- self . connectionHeaders = connectionHeaders
102- openSocketWithURLRequest ( request: request, delegate: delegate)
10399 self . connection = true
104100 }
105101
@@ -136,8 +132,10 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
136132 private func connect( ) {
137133 if socket? . readyState == . OPEN {
138134 // Support for Spring Boot 2.1.x
139- if ( connectionHeaders == nil ) {
140- connectionHeaders = [ StompCommands . commandHeaderAcceptVersion: " 1.1,1.2 " ]
135+ if connectionHeaders == nil {
136+ connectionHeaders = [ StompCommands . commandHeaderAcceptVersion: " 1.1,1.2 " ]
137+ } else {
138+ connectionHeaders ? [ StompCommands . commandHeaderAcceptVersion] = " 1.1,1.2 "
141139 }
142140 // at the moment only anonymous logins
143141 self . sendFrame ( command: StompCommands . commandConnect, header: connectionHeaders, body: nil )
@@ -496,3 +494,4 @@ public class StompClientLib: NSObject, SRWebSocketDelegate {
496494 }
497495 }
498496}
497+
0 commit comments