{"action":"created","issue":{"url":"https://api.github.com/repos/daltoniam/Starscream/issues/120","labels_url":"https://api.github.com/repos/daltoniam/Starscream/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/daltoniam/Starscream/issues/120/comments","events_url":"https://api.github.com/repos/daltoniam/Starscream/issues/120/events","html_url":"https://github.com/daltoniam/Starscream/issues/120","id":107658591,"number":120,"title":"Needs delay between socket creation and connect operation","user":{"login":"erez-rabih","id":813024,"avatar_url":"https://avatars.githubusercontent.com/u/813024?v=3","gravatar_id":"","url":"https://api.github.com/users/erez-rabih","html_url":"https://github.com/erez-rabih","followers_url":"https://api.github.com/users/erez-rabih/followers","following_url":"https://api.github.com/users/erez-rabih/following{/other_user}","gists_url":"https://api.github.com/users/erez-rabih/gists{/gist_id}","starred_url":"https://api.github.com/users/erez-rabih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erez-rabih/subscriptions","organizations_url":"https://api.github.com/users/erez-rabih/orgs","repos_url":"https://api.github.com/users/erez-rabih/repos","events_url":"https://api.github.com/users/erez-rabih/events{/privacy}","received_events_url":"https://api.github.com/users/erez-rabih/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-22T07:15:42Z","updated_at":"2015-09-22T19:22:57Z","closed_at":"2015-09-22T17:27:25Z","body":"Hi,\r\n\r\nI just started using Starscream and had some weird issue:\r\n\r\nWhen I tried to follow your example with an object that performs:\r\n```\r\nvar socket = WebSocket(url: NSURL(scheme: \"ws\", host: \"localhost:8080\", path: \"/\")!)\r\nsocket.delegate = self\r\nsocket.connect()\r\n```\r\nThe connection never happened.\r\nIt didn't arrive the server nor did it fire the delegate method I've set.\r\n\r\nWhat I had to do is to separate the socket creation and connect() method to two different functions which are called one after another:\r\n```\r\nfunc create() {\r\n  self.socket = WebSocket(url: NSURL(scheme: \"ws\", host: \"localhost:8080\", path: \"/\")!)\r\n  socket.delegate = self\r\n}\r\nfunc connect(){\r\n  socket.connect()\r\n}\r\n```\r\n\r\nThis way everything worked fine, the connection succeeded and I the delegate method got fired as expected.\r\n\r\nFrom what I can conclude there has to be some time interval between the socket creation and connection.\r\n\r\nI am using XCode 7 and swift 2\r\nI integrated Starscream vie cocoapods with the following line in the Podfile:\r\n  pod 'Starscream', '~> 1.0.0'\r\n\r\nDid anyone else get that weird issue? Am I misunderstanding something very basic here?\r\n\r\nThanks for the help in advance!"},"comment":{"url":"https://api.github.com/repos/daltoniam/Starscream/issues/comments/142391496","html_url":"https://github.com/daltoniam/Starscream/issues/120#issuecomment-142391496","issue_url":"https://api.github.com/repos/daltoniam/Starscream/issues/120","id":142391496,"user":{"login":"nuclearace","id":1211049,"avatar_url":"https://avatars.githubusercontent.com/u/1211049?v=3","gravatar_id":"","url":"https://api.github.com/users/nuclearace","html_url":"https://github.com/nuclearace","followers_url":"https://api.github.com/users/nuclearace/followers","following_url":"https://api.github.com/users/nuclearace/following{/other_user}","gists_url":"https://api.github.com/users/nuclearace/gists{/gist_id}","starred_url":"https://api.github.com/users/nuclearace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuclearace/subscriptions","organizations_url":"https://api.github.com/users/nuclearace/orgs","repos_url":"https://api.github.com/users/nuclearace/repos","events_url":"https://api.github.com/users/nuclearace/events{/privacy}","received_events_url":"https://api.github.com/users/nuclearace/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T19:22:57Z","updated_at":"2015-09-22T19:22:57Z","body":"@erez-rabih It's in the Swift language. If there's no reference to an object it will be deallocated. https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html#//apple_ref/doc/uid/TP40014097-CH20-ID48\r\n\r\n"}}