{"action":"closed","issue":{"url":"https://api.github.com/repos/koute/stdweb/issues/140","repository_url":"https://api.github.com/repos/koute/stdweb","labels_url":"https://api.github.com/repos/koute/stdweb/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/koute/stdweb/issues/140/comments","events_url":"https://api.github.com/repos/koute/stdweb/issues/140/events","html_url":"https://github.com/koute/stdweb/issues/140","id":300799690,"number":140,"title":"[Question] How to get a slice of bytes of websocket blob?","user":{"login":"Unmoving","id":16563063,"avatar_url":"https://avatars0.githubusercontent.com/u/16563063?v=4","gravatar_id":"","url":"https://api.github.com/users/Unmoving","html_url":"https://github.com/Unmoving","followers_url":"https://api.github.com/users/Unmoving/followers","following_url":"https://api.github.com/users/Unmoving/following{/other_user}","gists_url":"https://api.github.com/users/Unmoving/gists{/gist_id}","starred_url":"https://api.github.com/users/Unmoving/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Unmoving/subscriptions","organizations_url":"https://api.github.com/users/Unmoving/orgs","repos_url":"https://api.github.com/users/Unmoving/repos","events_url":"https://api.github.com/users/Unmoving/events{/privacy}","received_events_url":"https://api.github.com/users/Unmoving/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-27T21:29:07Z","updated_at":"2018-02-28T20:15:58Z","closed_at":"2018-02-28T20:15:58Z","author_association":"CONTRIBUTOR","body":"Hello!\r\n\r\nI try to send bytes encoded by bincode through the websocket. On client side I would like to deserialize the data, but for that I need something like:\r\n\r\n```\r\nws.add_event_listener(|event: SocketMessageEvent| {\r\n   let decoded_message: Message = deserialize(&event.data()[..]).unwrap();\r\n   alert(&format!{\"Message from WS: {:?}\", decoded_message});\r\n});\r\n```\r\n\r\nThis gives \r\n\r\n> cannot index into a value of type `stdweb::webapi::events::socket::SocketMessageData`\r\n\r\nSo I need some way to slice into the actual data. Any nice approaches I miss?\r\n\r\nI tried with:\r\n\r\n```\r\nlet decoded_message: Message = deserialize(&event.data().into_array_buffer().unwrap()[..]).unwrap();\r\n```\r\n\r\nand same for blob.\r\n\r\nAfter having a look at the code, I can't even get access to the underlying Reference.\r\n\r\nMaybe my usecase is special, but could you point me in the right direction, please?\r\n\r\nI know (or think that I do at least) how to do it in plain js, but that's something I would like to avoid."}}
{"actor":{"display_login":"Unmoving"}}