{"action":"opened","issue":{"url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/issues/49","labels_url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/issues/49/comments","events_url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/issues/49/events","html_url":"https://github.com/vibe-project/vibe-javascript-client/issues/49","id":56123369,"number":49,"title":"HTTP long polling transport should allow to exchange binary message","user":{"login":"flowersinthesand","id":1095042,"avatar_url":"https://avatars.githubusercontent.com/u/1095042?v=3","gravatar_id":"","url":"https://api.github.com/users/flowersinthesand","html_url":"https://github.com/flowersinthesand","followers_url":"https://api.github.com/users/flowersinthesand/followers","following_url":"https://api.github.com/users/flowersinthesand/following{/other_user}","gists_url":"https://api.github.com/users/flowersinthesand/gists{/gist_id}","starred_url":"https://api.github.com/users/flowersinthesand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowersinthesand/subscriptions","organizations_url":"https://api.github.com/users/flowersinthesand/orgs","repos_url":"https://api.github.com/users/flowersinthesand/repos","events_url":"https://api.github.com/users/flowersinthesand/events{/privacy}","received_events_url":"https://api.github.com/users/flowersinthesand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/milestones/12","labels_url":"https://api.github.com/repos/vibe-project/vibe-javascript-client/milestones/12/labels","id":958112,"number":12,"title":"3.0.0-Alpha12","description":"","creator":{"login":"flowersinthesand","id":1095042,"avatar_url":"https://avatars.githubusercontent.com/u/1095042?v=3","gravatar_id":"","url":"https://api.github.com/users/flowersinthesand","html_url":"https://github.com/flowersinthesand","followers_url":"https://api.github.com/users/flowersinthesand/followers","following_url":"https://api.github.com/users/flowersinthesand/following{/other_user}","gists_url":"https://api.github.com/users/flowersinthesand/gists{/gist_id}","starred_url":"https://api.github.com/users/flowersinthesand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowersinthesand/subscriptions","organizations_url":"https://api.github.com/users/flowersinthesand/orgs","repos_url":"https://api.github.com/users/flowersinthesand/repos","events_url":"https://api.github.com/users/flowersinthesand/events{/privacy}","received_events_url":"https://api.github.com/users/flowersinthesand/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2015-01-30T10:10:46Z","updated_at":"2015-01-31T12:27:19Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2015-01-31T12:27:19Z","updated_at":"2015-01-31T12:27:19Z","closed_at":null,"body":"Along the same lines with https://github.com/vibe-project/vibe-protocol/issues/54, it's not a big deal to land the feature to modern browsers. But, the challenge is to deal with old browsers.\r\n\r\nThe required features are [Typed Arrays](http://caniuse.com/#feat=typedarrays) and [XMLHttpRequest 2](http://caniuse.com/#feat=xhr2). A browser implementing them, modern browsers, has no problem. Considering our browser support policy, the browsers in question, old browsers, are Internet Explorer 6, 7, 8 and 9.\r\n\r\nI've failed to find out how binary data can be utilized in a browser where even Type Arrays is not available. Since the important purpose of using binary is performance, I'm not sure how much the fallback can complement the performance penalty as well. For that reason, now I'm thinking to drop support for old browsers as to binary features. Therefore, if binary features are used in writing application, it should not affect IE 6, 7, 8 and 9 or drop support for them.\r\n\r\nThough if you have a use case about binary on IE 6, 7, 8 and 9, please let me know. To implement the feature on such old browsers somehow or other, the following way may be available:\r\n\r\n* `Uint8Array`, `ArrayBuffer`, `atob`, `btoa`, and so on should be available on global.\r\n    * [Typed Arrays fallback](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js) and [Base64 fallback](https://github.com/davidchambers/Base64.js) can be used.\r\n* When establishing a connection, adds a query param, `base64`, to transport URI setting it to `true` just like HTTP request header, if XMLHttpRequest 2 is not supported. \r\n    * If `XMLHttpRequest` instance's `responseType` is `undefined`, it is not XMLHttpRequest 2.\r\n* To send a binary message from the client to the server,\r\n    * The client converts the given `ArrayBuffer` representing binary data to Base64 encoded string and deals with it as plain text message marking it as binary message.\r\n        * Using query: adds a param, `base64`, to URI setting it to `true`.\r\n        * Using message format: text message whose value is `hello` is `1hello` and binary message whose value is `2aGVsbG8` is `22aGVsbG8`.\r\n    * When a POST request is arrived, the server determines to fire either text or binary event by checking if it is a plain text or Base64 encoded text.\r\n* To send a binary message from the server to the client.\r\n    * The server converts the given binary data to Base64 encoded string and deals with it as plain text message marking it as binary message. It should be done only for those who have `base64` param in transport URI.\r\n        * Using message format: text message whose value is `hello` is `1hello` and binary message whose value is `2aGVsbG8` is `22aGVsbG8`.\r\n    *  When a message is arrived, the client determines to fire either text or binary event by checking if it is a plain text or Base64 encoded text. If it is Base64 encoded text, it should be converted to `ArrayBuffer` first and be fired."}}