HTTP streaming transport should allow to exchange binary message #56

Closed
flowersinthesand opened this Issue Feb 2, 2015 · 2 comments

Projects

None yet

1 participant

@flowersinthesand
Contributor

There are two approaches to achieve this feature.

  • Defining a new message format embracing both text and binary message.
  • Using Binary-to-text encoding with the current format.

HTTP streaming transport should be available on browser where XMLHttpRequest 2 and Typed Arrays are available like long polling transport. It will be covered in Vibe JavaScript Client first and accordingly RI will be updated.

@flowersinthesand flowersinthesand added this to the 3.0.0-Alpha12 milestone Feb 2, 2015
@flowersinthesand flowersinthesand referenced this issue in vibe-project/vibe-javascript-client Feb 2, 2015
Closed

HTTP streaming transport should allow to exchange binary message #53

@flowersinthesand
Contributor

Following vibe-project/vibe-javascript-client#53, this feature will be implemented using Base64.

@flowersinthesand
Contributor

Simple test.

Server

var vibe = require("./lib");
var http = require("http");
var url = require("url");

var server = vibe.transport.createHttpServer().on("transport", function(transport) {
    console.log('opened');
    transport.on("text", function(message) {
        console.log("on text", message);
        transport.send(message);
    }).on("binary", function(message) {
        console.log("on binary", message, message.toString());
        transport.send(message);
    });
});

http.createServer().on("request", function(req, res) {
    if (url.parse(req.url).pathname === "/vibe") {
        server.handle(req, res);
    }
}).listen(8080);

// > opened
// on text hello
// on binary <Buffer 68 65 6c 6c 6f> hello

Client

var vibe = require("./lib");
var transport = vibe.transport.createHttpStreamTransport("http://localhost:8080/vibe?transport=stream");
transport.on("open", function() {
    console.log('opened');
    transport.send("hello");
    transport.send(new Buffer([104,101,108,108,111])); // equals to new byte[]{'h','e','l','l','o'}
}).on("text", function(message) {
    console.log("on text", message);
}).on("binary", function(message) {
    console.log("on binary", message, message.toString());
}).open();

// > opened
// on text hello
// on binary <Buffer 68 65 6c 6c 6f> hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment