Questions tagged [msgpack]

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run

require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

MessagePack is available for many languages:

  • C
  • C++
  • D
  • Erlang
  • Go
  • Haskell
  • Java
  • OCaml
  • Python
  • Perl
  • PHP
  • Ruby
  • Scala
409 questions
0
votes
1 answer

msgpack - unpack data from php service using js

Hi have created a XMLHttpRequest and get the resp by using the following code. var xhr = new XMLHttpRequest(); xhr.open("GET", URL, true); xhr.responseType = "text"; xhr.onload = function () { debugger; var…
Arahim
  • 303
  • 1
  • 6
  • 14
0
votes
1 answer

Can't understand how MsgPack packs data

I'm trying to investigate MsgPack's source code. In the example there's a fragment: std::vector vec; vec.push_back("MessagePack"); msgpack::sbuffer sbuf; msgpack::pack(sbuf, vec); I see in /usr/include/msgpack/object.hpp that an…
Andrey G.A
  • 305
  • 4
  • 20
0
votes
1 answer

How to receive post data in node.js as sent?

Client sending POST request with msgpack data as postbody. I can receive the chunk data as string, msgpack module not able to accept the string input for unpack the data. how to receive the post data as msgpack (not as string)? so that…
Nadhas
  • 5,421
  • 2
  • 28
  • 42
0
votes
2 answers

MsgPack Woes - Destructor, pack_raw_body, Etc

I am using MsgPack as part of a custom back-end I am creating for the SOCI C++ database access API. Initially, some of my SOCI classes had MsgPack::sbuffer objects as member variables, but I ran into some problems in the destructor of my SOCI object…
Dan Forbes
  • 2,734
  • 3
  • 30
  • 60
0
votes
1 answer

Ruby/Rack/Sinatra encoding of a MessagePack POST

I am trying to build an API with Sinatra and MessagePack but I am about to shoot myself :) So I am using curl to do a POST: curl -X POST -H "Content-Type: application/x-msgpack" --data-binary…
user287689
0
votes
1 answer

msgpack / messagepack not serializing php

I am attempting to access session variables set via php stored in memcached from node. I would really like the format of the stored session data to be in JSON. I found msgpack and that looked like it might do the job, however, a console.log of the…
Grant
  • 105
  • 8
0
votes
1 answer

Npm registry error when installing msgpack-x

When I execute npm install msgpack-x I get an error which says 'msgpack-x' is not in the npm registry. I am very new to this, any idea what I might be missing?
0
votes
1 answer

MsgPack serialization throw an error

I trying to create a serializer like this var serializer = MsgPack.Serialization.MessagePackSerializer.Create(); It will serialize the class tickdata. namespace TickDataDefinition { public class tickdata { public List _data=new…
user3398315
  • 331
  • 6
  • 17
0
votes
1 answer

How to serialize an mixed type object array using MessagePack in C#

I have an application which communicates over TCP/IP method, and needs to serialize some data over to the device. In the application, I would like to serialize a mixed type object array, which includes string, double array, and some integer..etc.…
user2386301
  • 412
  • 1
  • 5
  • 18
0
votes
1 answer

Python msgpack module: packb and newlines

Currently we are using json to code\decode data in our data processing software. But we found any JSON implementation slow - we tried simplejson, ujson etc. - so we're looking for an alternative. We use some other programs to work with data, and…
Spaceman
  • 1,185
  • 4
  • 17
  • 31
0
votes
2 answers

Can't compile msgpack Python extension under windows

When I try to compile msgpack under windows with visual studio 2008 professional version by doing Python setup.py build I get msgpack/_packer.cpp(316) : fatal error C1083: Cannot open include file: 'stdint. h': No such file or…
mahonya
  • 9,247
  • 7
  • 39
  • 68
0
votes
1 answer

How to use msgpack in xcode project?

I installed msgpack with brew and can compile the sample code with gcc msgpacktest.c -lmsgpack in the command line. But when I add the header in test.m, a class in my iOS project and add -lmsgpack in Compile Sources of Build Phases, I still get the…
user299648
  • 2,769
  • 6
  • 34
  • 43
0
votes
1 answer

msgpack packing char array in C

How do I work with msgpack_pack_raw and msgpack_pack_raw_body to send an unsigned char array to more importantly, how to retrieve (unpack) it? What I have done is as follows: msgpack_sbuffer* buffer = msgpack_sbuffer_new(); msgpack_packer* pk =…
Arash
  • 588
  • 1
  • 6
  • 16
0
votes
1 answer

MessagePack unpack fails with large Metasploit Framework message in C received via Libcurl

First off, I used How do I unpack and extract data properly using msgpack-c? to figure out how to properly unpack data since MessagePack's own C API documentation isn't great. Though, http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language…
mordocai
  • 83
  • 7
0
votes
1 answer

Pass Object class to server method using Message Pack RPC

I want to make a call from a client to a method in the server and I want to pass to the method an argument that is a class written by me. How can I do this using MsgPack RPC. I know how to pass an int a vector or a string.
exilonX
  • 1,712
  • 3
  • 26
  • 50