Giter Club home page Giter Club logo

pomeloc's Introduction

pomeloc

a pomelo protocol unity-c# stub generator.

pomeloc 是一个针对pomelo 的协议生成unity3d-c#存根代码的工具,需要配合这个demo[pomelo-unitychat]中的客户端代码使用

安装方法

需要cmake

windows:

需要vs2015

open your vcvarsall.bat 
cd build
run build.cmd

使用

pomeloc.exe --csharp  [--ns Proto] serverProtos.json clientProtos.json

生成clientProto.cs后就可以在代码里正常的使用了,以chatofpomelo的send函数为例

 public void send(string message)
    {
        chatHandler.send(
            "pomelo",
            message,
            user,
            "*"
            );
    }

生成的存根如下:

namespace Proto
{
    namespace chat
    {
        public class chatHandler
        {
            public static PomeloClient pc = null;
            public static bool send(string rid,string content,string from,string target)
            {
                JsonData data = new JsonData();
                data["rid"] = rid;
                data["content"] = content;
                data["from"] = from;
                data["target"] = target;
                pc.notify("chat.chatHandler.send", data);
                return true;
            }
        }
    }
}

规则

  • 如果clientProto.json有而serverProto.json没有,则认为是notify
  • 如果clientProto.json有并且serverProto.json有,则认为是request
  • 如果只有serverProto.json有,则认为是服务器主动下发,代码中使用ServerEvent.xxx调用

要求前端默认开启dict,proto

客户端连接成功后需要手动更新对应存根代码的客户端对象pc

详细使用可以看demo

pomeloc's People

Contributors

flamefox avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

gameweb

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.