Git Product home page Git Product logo

Comments (15)

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

Changed handler adressing, but still doesnt work for me.

public void Deserialize(byte[] rawMessage) {
    Dictionary<MessagePackObject, MessagePackObject> mpoDict = MessagePackSerializer.Create<Dictionary<MessagePackObject, MessagePackObject>>().Unpack(new MemoryStream(rawMessage));
    Dictionary<String, MessagePackObject> dict = mpoDict.ToDictionary(kv => (String)kv.Key, kv => kv.Value);
    MessagePackObject theValue;

    if (dict.TryGetValue("error", out theValue))
    {
        var error = (String)theValue;
    }
    else if (dict.TryGetValue("engine", out theValue))
    {
        var engine = (String)theValue;
        if(engine.Equals("@LOGIN")){Server.Client.Handler.LoginHandler(dict)}
        else if(engine.Equals("@REGISTER")){Server.Client.Handler.RegisterHandler(dict)}
        else if(engine.Equals("@MESSAGE")){Server.Client.Handler.MessageHandler(dict)}
        else if(engine.Equals("@LOGOUT")){Server.Client.Handler.LogoutHandler(dict)}
        else{Server.Clinet.Handler.ErrorHandler.throwError("Unrecognized Engine")}
    }
}

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

Could you use MessagePackObjectDictionary to represents dynamic message? Its built-in serializer now can handle nested dynamic element, so it might solve your problem.

MessagePackObjectDictionary mpoDict = MessagePackSerializer.Create<MessagePackObjectDictionary>().Unpack(new MemoryStream(rawMessage));
// or, you can simply do as following:
// var mpoDict = Unpacking.UnpackDictionary(rawData).Value;

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

thanks for the fast reply :)
Seems to work for me :) but i dont really like the try and Error thing :(

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

Do you say that you want to ensure exact solution, or hope to improve documents in the first place? If former, please tell me expected & actual issue you faced. If latter, I will be happy if you told me what content did you like to see.
As a first step of latter, I updated wiki to publish sample codes.

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

Something like a package header would be awesome, so that the package destination can be instantly assigned and the payload transmitted to the class, which is working with it, so you can avoid the try&error stuff

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

I might misunderstand what the 'try&error' means. Do you mean that an ability to embed a kind of 'type hint' in the packed bytes to reduce hand-made detection of actual type like if statements in your code?

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

yeah exactly all the if statements are problematic. The app is managed with a massresponse servernetwork, but this network don't have unlimited CPU, too. So creating the dict, gettin one var of it, "try&error" it out, till you find what you are looking for or sorting it out, cause of malformed package.

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

Then transmit to the subengine, which evaluates the rest of the package etc. etc.

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

it would be more useful to have a so called package header, which don't need the creation of a dict and so on. So data can be evaluated in few less steps and cpu&RAM would be saved. I do not want to work with googlestuff but if you are interested in packageheaders, there is a extension called protobuf supporting exact these headers. Is it implementable here?

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

I see. I'll study the extension of protobuf and tuckle to dynamic type with existing msgpack ext types.

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

nice. We would really like to use your Packageformat in our App :)

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

@Jan-Heapster

I've written the spec draft. Would you review it? https://gist.github.com/yfakariya/fb6d5c66fa4d8a82346b

from msgpack-cli.

Jan-Heapster avatar Jan-Heapster commented on July 18, 2024

Hey!

I am goin to take a detailed look on it tomorrow.
But i am very happy about to hear that you are still engaged.

CYU tomorrow

Am 11.01.2015 um 15:08 schrieb Yusuke Fujiwara:

@Jan-Heapster https://github.com/Jan-Heapster

I've written the spec draft. Would you review it?
https://gist.github.com/yfakariya/fb6d5c66fa4d8a82346b


Reply to this email directly or view it on GitHub
#47 (comment).

Jan Weber / Backenddeveloper
[email protected] mailto:[email protected]/ + 49 1573 64 14 294

heapsterDev
http://www.invitu.de

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

@Jan-Heapster I released this feature in 0.6.0-beta2 release. Could you try it?

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

Fixed in 0.6.0.

from msgpack-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.