Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending header parameters only on initial connection. #911

Closed
yilmazalican opened this issue Dec 17, 2017 · 2 comments
Closed

Sending header parameters only on initial connection. #911

yilmazalican opened this issue Dec 17, 2017 · 2 comments

Comments

@yilmazalican
Copy link

yilmazalican commented Dec 17, 2017

Hello.
I'm designing a chat app in ios.
i've designed a singleton class for the manager and socket. But the manager's extraHeaders options called on initial connection. Even changing the config of the manager to a new one does not effects.

class APISocket {
    private let manager = SocketManager(socketURL: URL(string:"http://172.27.101.123:4000")!)
    static let shared = APISocket()
    let socket:SocketIOClient
    private init(){
        self.socket = manager.defaultSocket
    }

    func establishConnection(token:String){
        if(self.socket.status != .connected){
            self.manager.config = SocketIOClientConfiguration(arrayLiteral: .compress,.connectParams(["Authorization": token]))
            self.socket.connect()
        }
    }
    
    func disconnectSocket(){
        if(self.socket.status == .connected){
            self.socket.disconnect()
        }
    }
@nuclearace
Copy link
Member

Yes.. Unless you force polling, headers are only sent on the initial connection. Otherwise a websocket connection is established and they aren't sent again.

@archerhan
Copy link

Oh dude, this saved me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants