Skip to content

Instantly share code, notes, and snippets.

@faisal00813
Last active June 3, 2023 15:56
Show Gist options
  • Select an option

  • Save faisal00813/c8028de3e4a37f1ce92edc443d3aba8c to your computer and use it in GitHub Desktop.

Select an option

Save faisal00813/c8028de3e4a37f1ce92edc443d3aba8c to your computer and use it in GitHub Desktop.

Revisions

  1. faisal00813 revised this gist Nov 21, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion messagepack_client.js
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,6 @@ request.post(
    // "author": "",
    // "license": "ISC",
    // "dependencies": {
    // "express": "^4.16.2",
    // "msgpack-lite": "^0.1.26",
    // "request": "^2.83.0"
    // }
  2. faisal00813 revised this gist Nov 21, 2017. No changes.
  3. faisal00813 revised this gist Nov 21, 2017. 1 changed file with 22 additions and 1 deletion.
    23 changes: 22 additions & 1 deletion messagepack_client.js
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,25 @@ request.post(
    return console.error('upload failed:', err);
    }
    console.log('Upload successful! Server responded with:', msgpack.decode(body));
    });
    });


    // package.json
    // ----------
    // {
    // "name": "msgpack_webserver",
    // "version": "1.0.0",
    // "description": "",
    // "main": "index.js",
    // "scripts": {
    // "test": "echo \"Error: no test specified\" && exit 1"
    // },
    // "author": "",
    // "license": "ISC",
    // "dependencies": {
    // "express": "^4.16.2",
    // "msgpack-lite": "^0.1.26",
    // "request": "^2.83.0"
    // }
    // }

  4. faisal00813 revised this gist Nov 21, 2017. No changes.
  5. faisal00813 created this gist Nov 21, 2017.
    27 changes: 27 additions & 0 deletions messagepack_client.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    const request = require('request')
    const msgpack = require("msgpack-lite");

    var packedData = msgpack.encode({
    "str" : "Something",
    "number" : 4.0,
    "arr": ["one","two"],
    "nClass": {
    "doubleNumber" : 35.0,
    "nums" : [34,23]
    },
    "bool":true
    });
    request.post(
    {
    url:'http://localhost:9000/user/msgPackTest',
    headers: {
    'content-type': 'application/octet-stream'
    },
    body: packedData,
    encoding: null
    }, function optionalCallback(err, httpResponse, body) {
    if (err) {
    return console.error('upload failed:', err);
    }
    console.log('Upload successful! Server responded with:', msgpack.decode(body));
    });