bairuo / bump Goto Github PK
View Code? Open in Web Editor NEWTencent 72 hours summer camp
Tencent 72 hours summer camp
如果我对你的网络架构没理解错的话......
大概实现这种....
/// 某个模板类.
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); ...
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.