Socket.io-client-swift: Help wanted: How to pass in query string when connecting to socketio endpoint?

Created on 3 Aug 2015  路  10Comments  路  Source: socketio/socket.io-client-swift

Can just append "?token=xxx" to the socketio url?

question

Most helpful comment

Updated for 2017

var socket = SocketIOClient(socketURL: URL(string: "localhost:8080")!, config: [.connectParams(["<key>" : "<value>"])])

All 10 comments

let socket = SocketIOClient(socketURL: "localhost:8080", opts: ["connectParams": ["thing": "value"]])

You could use connectParams

what's the object-c way to do this?

SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL: @"localhost:8080" opts: @{@"connectParams": @{@"thing": @"value"}}];

Works! Thanks!

Updated for 2017

var socket = SocketIOClient(socketURL: URL(string: "localhost:8080")!, config: [.connectParams(["<key>" : "<value>"])])

Hi ,
I don't find socket io client with this params.
Is there any alternative method to pass query parameters on connect method ?

@mohdsafadsaal The config stuff has moved to the SocketManager in the latest version.

how to use connect parameters in swift 4

@nuclearace Can you please provide the demo using SocketManager?
I am getting difficulty to connect to socket server with authorization header.
Appreciate your help!

@bdavid68 It's crude, but this shows some basic usage: https://github.com/nuclearace/socket.io-client-testing/blob/master/Sources/main.swift

Was this page helpful?
0 / 5 - 0 ratings