Advertisement
ds1239

Untitled

Feb 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.87 KB | None | 0 0
  1. socket.event.message = { message in
  2.             if let msgString = message as? String,
  3.                 let data = msgString.data(using: .utf8),
  4.                 let json = try! JSONSerialization.jsonObject(with: data) as? [String: Any],
  5.                 let type = json["type"] as? String
  6.             {
  7.                 if type == "question"
  8.                 {
  9.                     print("Got a question!")
  10.                     print(json)
  11.                 }
  12.                 else if type == "broadcastEnded"
  13.                 {
  14.                     self.connectToHQSocket(url: url)
  15.                 }
  16.                 else
  17.                 {
  18.                     print(type)
  19.                 }
  20.             }
  21.             if let json = message as? [String: Any],
  22.                 let type = json["type"] as? String
  23.             {
  24.                 print(type)
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement