Nifty Procrastination Machine
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    dgram-browserifypublic

    Kind of udp support for the browser : replace the dgram module. Behind the scene, a socket.io/udp proxy makes this possible.

    dgram-browserify is a wrapper around simudp for automatic browserify support.

    Be careful, for the moment, the main browserify version provides a broken implementation of Buffer. That's why this version should be used..

    Installation

    $ npm install dgram-browserify

    Use

    Server-side, the proxy server should be launched :

    var server = require('http').createServer();
     
    require('dgram-browserify').listen(server);
     
    server.listen(8080);

    Note : see listen options

    Browser-side with browserify :

    var dgram = require('dgram');
     
    //be sure Buffer is present
    var Buffer = require('buffer').Buffer;
     
    var socket = dgram.createSocket('udp4');
     
    var hello = new Buffer('hello');
    socket.send(hello, 0, hello.length, 3000, 'anywhere.com');
     
    socket.on('message', function(buf, rinfo) {
      //...
    });
     
    //you've understood, it's dgram for the browser...

    Keywords

    none

    install

    npm i dgram-browserify

    Downloadsweekly downloads

    34

    version

    0.0.13

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar