Code Monkey home page Code Monkey logo

bump's People

Contributors

bairuo avatar dragoonkiller avatar

Watchers

 avatar

bump's Issues

呃关于那个新的网络接口.....

如果我对你的网络架构没理解错的话......
大概实现这种....

/// 某个模板类.
class Synchronizer<T>
{
    public T data { get; set; } // 可能要使用Getter/Setter函数来避免拷贝形式的捕获.
    Synchronizer(string name)
    {
        Client.AddListener((...) => { ... }); // lambda表达式自动捕获本地变量T.
    }
    ~Synchronizer()
    {
        Client.DelListener((...) => { ... });
    }
    Set(T newdata)
    {
        data = newdata; // 似乎应为值类型(struct), 直接拷贝赋值.
        Client.instance.Send(new Protocol(...)); // 或许需要一些转换...
    }
}

转换成protocol的方法可以让调用者自己定义, 这样仍然不用动网络框架的代码...
写脚本的时候只需要...

class MyScript : MonoBehaviour
{
    Synchronizer<Int> propertyA; // <- 单变量同步.
    struct DataToBeSync
    {
        string ID;
        float x;
        float y;
    };
    Synchronizer<DataToBeSync> data; // <- 多变量同步.
    ...
    void Update()
    {
        propertyA.Set(1);        ...
    }
}

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.