"Simplemsgpack.net" publishes a Msgpack protocol C # version of the parse Open Source Library

Source: Internet
Author: User
Tags unpack

These two years have been concerned about the application of this IOCP in network communication, of course, the transmission of data is often needed. This year contacted the Msgpack format, and found that he used to do the transmission of data packaging is really cool. Because he can pack binary data directly, no conversion is required. Some people would say that it's not difficult to pack, yes, that's right. But there are standard format protocols, why not use them directly. Looking at the next Msgpack protocol format, compression is basically done to maximize. Http://msgpack.org can understand its protocol format.

My main work is Delphi to develop, Delphi inside has qmsgpack. I also wrote a simplemsgpack used to be very comfortable, I would like to see C # in the evening, after all, C # to do the client is also good. Using the next C # version of Msgpack parsing, it is not very accustomed to, maybe I am a delphier. Later, I decided to write a simplemsgpack net version. Now basically molded. The following will continue to add something new. Can be downloaded directly on Git, or you can find the input simplemsgpack in nuget to download. Please download the source code on GitHub. If there is any bug, please be sure to contact me, I will arrange the repair as soon as possible.

Compilation Environment:

VS2013 NET Framework 4.5 (can be compiled under VS2010, other versions not tested)

Open Source Address: Https://github.com/ymofen/SimpleMsgPack.Net

Wrote a few simple test code. It should be clear to everyone.

Msgpack Msgpack =NewMsgpack (); Msgpack. Forcepathobject ("P.name"). Asstring ="Zhang San"; Msgpack. Forcepathobject ("P.age"). Asinteger = -; Msgpack. Forcepathobject ("P.datas"). Asarray.add ( -); Msgpack. Forcepathobject ("P.datas"). Asarray.add ( the); Msgpack. Forcepathobject ("P.datas"). Asarray.add ("John Doe"); Msgpack. Forcepathobject ("P.datas"). Asarray.add (3.1415926); //Pack FileMsgpack. Forcepathobject ("P.filedata"). Loadfileasbytes ("C:\\a.png"); //Pack Msgpack binary    byte[] Packdata =Msgpack.    Encode2bytes (); Msgpack Unpack_msgpack=NewMsgpack (); //Unpack MsgpackUnpack_msgpack.    Decodefrombytes (Packdata); System.Console.WriteLine ("name:{0}, Age:{1}", Unpack_msgpack. Forcepathobject ("P.name"). Asstring, Unpack_msgpack. Forcepathobject ("P.age").    Asinteger); Console.WriteLine ("=================================="); System.Console.WriteLine ("Use the Index property, length{0}:{1}", Unpack_msgpack. Forcepathobject ("P.datas"). Asarray.length, Unpack_msgpack. Forcepathobject ("P.datas"). asarray[0].    asstring); Console.WriteLine ("=================================="); Console.WriteLine ("Use foreach statement:"); foreach(Msgpack IteminchUnpack_msgpack. Forcepathobject ("P.datas") {Console.WriteLine (item).    asstring); }    //Unpack FiledataUnpack_msgpack. Forcepathobject ("P.filedata"). Savebytestofile ("C:\\b.png"); Console.read ();

Results of the output:

See if it suits you. It is still in the test, and of course it is not used in specific projects. But the back will slowly use up, I am ready to use to do communication when the data packaging. If you find a bug, please contact me.

qq:185511468,
Email:[email protected]
can also go into the group [Programmer's House 146605007]@ Me

"Simplemsgpack.net" publishes a Msgpack protocol C # version of the parse Open Source Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.