New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP long polling transport should allow to exchange binary message #54

Closed
flowersinthesand opened this Issue Jan 30, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@flowersinthesand
Contributor

flowersinthesand commented Jan 30, 2015

By setting HTTP request/response content-type header to application/octet-stream, HTTP message can contain binary data and it's enough to land this feature to RI.

Practically, long polling transport should be available on old browser and this constraint limits transport protocol as usual. It will be covered in Vibe JavaScript Client and accordingly RI will be updated.

@flowersinthesand

This comment has been minimized.

Show comment
Hide comment
@flowersinthesand

flowersinthesand Jan 30, 2015

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.createHttpLongpollTransport("http://localhost:8080/vibe?transport=longpoll");
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
Contributor

flowersinthesand commented Jan 30, 2015

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.createHttpLongpollTransport("http://localhost:8080/vibe?transport=longpoll");
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