nuclearace / Socket.IO-Client-Swift

socket.io-client for Swift
Other
361 stars 53 forks source link

ios swift socket data send problem #171

Closed Darshi123 closed 5 years ago

Darshi123 commented 5 years ago

hello

i did below code but not success anyone can help i try username = 56 like id i want to send to socket server from client but connection success but data not able to send to server socket

anyone can help or guide ?

override func viewDidLoad() { super.viewDidLoad()

    let manager = SocketManager(socketURL: URL(string: "https://instaridellc.com:4042")!, config: [.log(true), .forcePolling(true)])

    let socket = manager.defaultSocket

    socket.on(clientEvent: .connect) {data, ack in
        print("socket connected")

    }
    socket.emitWithAck("username", 56).timingOut(after: 0) {data in
        // do something with data

    }

    socket.emitWithAck("username", 56).timingOut(after: 0) {data in
        // do something with data

    }

socket.connect(

    )

    socket.emitWithAck("username", 56).timingOut(after: 0) {data in
        // do something with data

    }
nuclearace commented 5 years ago

@Darshi123 Your issue is that you're declaring the manager as a local variable. See the FAQs for more on this issue.