{"action":"opened","issue":{"url":"https://api.github.com/repos/socketio/socket.io-client-swift/issues/391","repository_url":"https://api.github.com/repos/socketio/socket.io-client-swift","labels_url":"https://api.github.com/repos/socketio/socket.io-client-swift/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/socketio/socket.io-client-swift/issues/391/comments","events_url":"https://api.github.com/repos/socketio/socket.io-client-swift/issues/391/events","html_url":"https://github.com/socketio/socket.io-client-swift/issues/391","id":159767125,"number":391,"title":"Socket.on doest work , but emit does","user":{"login":"arashdoescode","id":11389658,"avatar_url":"https://avatars.githubusercontent.com/u/11389658?v=3","gravatar_id":"","url":"https://api.github.com/users/arashdoescode","html_url":"https://github.com/arashdoescode","followers_url":"https://api.github.com/users/arashdoescode/followers","following_url":"https://api.github.com/users/arashdoescode/following{/other_user}","gists_url":"https://api.github.com/users/arashdoescode/gists{/gist_id}","starred_url":"https://api.github.com/users/arashdoescode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arashdoescode/subscriptions","organizations_url":"https://api.github.com/users/arashdoescode/orgs","repos_url":"https://api.github.com/users/arashdoescode/repos","events_url":"https://api.github.com/users/arashdoescode/events{/privacy}","received_events_url":"https://api.github.com/users/arashdoescode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-11T10:27:35Z","updated_at":"2016-06-11T10:27:35Z","closed_at":null,"body":"Here's the deal, I have been struggling to get socket.on working but so far nothing has work\r\n\r\nCode for serverside\r\n\r\n```\r\n\r\n  io.on(\"connection\", function(socket) {\r\n    socket.on(\"clickit\", function(data) {\r\n      console.log(\"You are clicking it\")\r\n      socket.emit(\"listeningHere\", \"data is here\");\r\n    });\r\n  });\r\n```\r\n\r\nThere are 3 viewController\r\n\r\n1. is to emit\r\n2. is to listen and do a popover\r\n3. is the popover view\r\n\r\n//\r\n//  FirstViewController.swift\r\n//  parcel\r\n//\r\n//  Created by Arash on 6/11/16.\r\n//  Copyright © 2016 Arash. All rights reserved.\r\n//\r\n\r\nimport UIKit\r\nimport SocketIOClientSwift\r\n\r\n\r\nclass FirstViewController: UIViewController {\r\n    \r\n    let socket: SocketIOClient = SocketIOClient(socketURL: NSURL(string: \"https://testing.herokuapp.com\")!,options: [.Log(true)])\r\n\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        socket.connect()\r\n        // Do any additional setup after loading the view.\r\n    }\r\n\r\n    @IBAction func buttonPressed(sender: AnyObject) {\r\n        socket.emit(\"clickit\")\r\n        \r\n    }\r\n}\r\n\r\nWhenever i click the button, it works the server receive it, but on the secondViewController, seems like it doesn't listen \r\n\r\n\r\n```\r\n\r\nimport UIKit\r\nimport SocketIOClientSwift\r\n\r\nclass SecondViewController: UIViewController {\r\n    \r\n    let socket: SocketIOClient = SocketIOClient(socketURL: NSURL(string: \"https://testing.herokuapp.com\")!,options: [.Log(true)])\r\n\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        \r\n        // Do any additional setup after loading the view.\r\n    }\r\n    \r\n    \r\n    override func viewDidAppear(animated: Bool) {\r\n        socket.on(\"listeningHere\") { data, ack in\r\n            print(data)\r\n            print(\"Im listening here\")\r\n            let vc = self.storyboard!.instantiateViewControllerWithIdentifier(\"dataBoard\") as! ThirdViewController\r\n            self.presentViewController(vc, animated: true, completion: nil)\r\n        }\r\n        \r\n   \r\n    }\r\n\r\n   \r\n}\r\n\r\n```\r\n\r\nWhat is the problem? everything looks perfect, but I don't why it doesnt listen.\r\n"}}
{"actor":{"display_login":"arashdoescode"}}