{"action":"closed","issue":{"url":"https://api.github.com/repos/primus/primus/issues/479","repository_url":"https://api.github.com/repos/primus/primus","labels_url":"https://api.github.com/repos/primus/primus/issues/479/labels{/name}","comments_url":"https://api.github.com/repos/primus/primus/issues/479/comments","events_url":"https://api.github.com/repos/primus/primus/issues/479/events","html_url":"https://github.com/primus/primus/issues/479","id":164523220,"number":479,"title":"Give the option to efficiently send binary data to and from the server","user":{"login":"githubaccount624","id":20170894,"avatar_url":"https://avatars.githubusercontent.com/u/20170894?v=3","gravatar_id":"","url":"https://api.github.com/users/githubaccount624","html_url":"https://github.com/githubaccount624","followers_url":"https://api.github.com/users/githubaccount624/followers","following_url":"https://api.github.com/users/githubaccount624/following{/other_user}","gists_url":"https://api.github.com/users/githubaccount624/gists{/gist_id}","starred_url":"https://api.github.com/users/githubaccount624/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/githubaccount624/subscriptions","organizations_url":"https://api.github.com/users/githubaccount624/orgs","repos_url":"https://api.github.com/users/githubaccount624/repos","events_url":"https://api.github.com/users/githubaccount624/events{/privacy}","received_events_url":"https://api.github.com/users/githubaccount624/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-08T12:45:15Z","updated_at":"2016-07-24T12:42:03Z","closed_at":"2016-07-24T12:42:03Z","body":"I'm writing a game. I'm looking for a way to send types like `Int16Array` to the server and handle them as a `Buffer` on the server. Reasons:\r\n\r\n1) The `binary` parser is four years old and spikes CPU usage to 100% and sometimes crashes the server when used. It's basically unusable if sending slightly large packets (arrays with 1000 elements, for example).\r\n\r\n2) The server doesn't have to parse the data (either via binary-unpack or JSON.parse) and then re-encode (via binary-pack or JSON.stringify). Thus it can simply relay the packet extremely quickly.\r\n\r\n3) Bandwidth efficiency: Instead of sending strings of numeric characters and commas, which quickly adds up for large arrays, we can simply send the packed numbers.\r\n\r\n4) Slightly more secure because the packets cannot be viewed in browser developer consoles (can still be viewed in proxy monitoring applications like Burp suite but requires much more effort)\r\n\r\n5) All underlying libraries that primus uses support it. Even [socket.io](http://socket.io/blog/introducing-socket-io-1-0/#binary) does. Native websockets in the browser does by setting `connection.binaryType = \"arraybuffer\";` We should be able to send binary data without it being stringified and parsed.\r\n\r\n6) Browsers support it with typed arrays and node supports it with the Buffer.\r\n\r\n7) People need this because browsers are becoming more powerful and websockets are increasingly being used for games/videos where efficiency is paramount.\r\n\r\n8) In Primus data already arrives as a Buffer. I just want to keep it that way with no parsing.\r\n\r\nI think the `ejson` parser supports it but I don't know what kind of overhead that has and it seems odd to still be using a `json` parser to be sending pure binary. Also I can't seem to find much information about `ejson` and either way, it's weird to be using a parser that's thousands of lines of code wherein all I really need is no parser at all."}}
{"actor":{"display_login":"lpinca"}}