{"action":"created","issue":{"url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/1","repository_url":"https://api.github.com/repos/ttdonovan/sc2-api-rs","labels_url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/1/comments","events_url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/1/events","html_url":"https://github.com/ttdonovan/sc2-api-rs/issues/1","id":259096746,"number":1,"title":"Graceful shutdown and cleanup","user":{"login":"Michael-F-Bryan","id":17380079,"avatar_url":"https://avatars2.githubusercontent.com/u/17380079?v=4","gravatar_id":"","url":"https://api.github.com/users/Michael-F-Bryan","html_url":"https://github.com/Michael-F-Bryan","followers_url":"https://api.github.com/users/Michael-F-Bryan/followers","following_url":"https://api.github.com/users/Michael-F-Bryan/following{/other_user}","gists_url":"https://api.github.com/users/Michael-F-Bryan/gists{/gist_id}","starred_url":"https://api.github.com/users/Michael-F-Bryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Michael-F-Bryan/subscriptions","organizations_url":"https://api.github.com/users/Michael-F-Bryan/orgs","repos_url":"https://api.github.com/users/Michael-F-Bryan/repos","events_url":"https://api.github.com/users/Michael-F-Bryan/events{/privacy}","received_events_url":"https://api.github.com/users/Michael-F-Bryan/received_events","type":"User","site_admin":false},"labels":[{"id":691908453,"url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/labels/help%20wanted","name":"help wanted","color":"33aa3f","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-09-20T09:23:14Z","updated_at":"2017-10-05T22:11:10Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"It's kinda annoying how the websockets library has a push-style of doing things (it fires off callbacks when things happen) instead of a pull-style (think iterator of messages) because making sure the listener thread shuts down gracefully when we want it to becomes a pain... \r\n\r\nOne possible way of doing things is to spin off the listener thread, passing an `Arc<AtomicBool>` (or `Arc<Mutex<bool>>`) to the `Client` which can function as a `running` flag. \r\n\r\nThen in a `Connection`'s shutdown method it'll set the `running` flag to `false` and wait on the listener thread's handle. For convenience you'd probably also make `Connection`'s drop impl call `shutdown()` automatically.\r\n\r\nMeanwhile on the `Client` side you can set a [timeout] when it first connects. When the timeout fires, `Client` will wake up and can check if it's still running, re-scheduling the timeout if it is and closing the connection otherwise.\r\n\r\nThat's all awfully convoluted though, so hopefully you can come up with a less hacky/racy solution :stuck_out_tongue_winking_eye: \r\n\r\n[timeout]: https://docs.rs/ws/0.7.3/ws/struct.Sender.html#method.timeout"},"comment":{"url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/comments/334606430","html_url":"https://github.com/ttdonovan/sc2-api-rs/issues/1#issuecomment-334606430","issue_url":"https://api.github.com/repos/ttdonovan/sc2-api-rs/issues/1","id":334606430,"user":{"login":"ttdonovan","id":10460,"avatar_url":"https://avatars3.githubusercontent.com/u/10460?v=4","gravatar_id":"","url":"https://api.github.com/users/ttdonovan","html_url":"https://github.com/ttdonovan","followers_url":"https://api.github.com/users/ttdonovan/followers","following_url":"https://api.github.com/users/ttdonovan/following{/other_user}","gists_url":"https://api.github.com/users/ttdonovan/gists{/gist_id}","starred_url":"https://api.github.com/users/ttdonovan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttdonovan/subscriptions","organizations_url":"https://api.github.com/users/ttdonovan/orgs","repos_url":"https://api.github.com/users/ttdonovan/repos","events_url":"https://api.github.com/users/ttdonovan/events{/privacy}","received_events_url":"https://api.github.com/users/ttdonovan/received_events","type":"User","site_admin":false},"created_at":"2017-10-05T22:11:10Z","updated_at":"2017-10-05T22:11:10Z","author_association":"OWNER","body":"TODO: look into https://crates.io/crates/tungstenite"}}
{"actor":{"display_login":"ttdonovan"}}