Created
January 3, 2020 10:28
-
-
Save Krishna21Soni13/449b7cce978d54637ecbe80301b24162 to your computer and use it in GitHub Desktop.
To get the participant list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func participantList(completion: @escaping (_ userList: [User]?) -> Void) { | |
guard let socket = manager?.defaultSocket else { | |
return | |
} | |
socket.on(kUserList) { [weak self] (result, ack) -> Void in | |
guard result.count > 0, | |
let _ = self, | |
let user = result.first as? [[String: Any]], | |
let data = UIApplication.jsonData(from: user) else { | |
return | |
} | |
do { | |
let userModel = try JSONDecoder().decode([User].self, from: data) | |
completion(userModel) | |
} catch let error { | |
print("Something happen wrong here...\(error)") | |
completion(nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment