Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在game和gate之间加入Dispatcher主要出于什么设计目的?以及主要解决什么问题? #95

Open
mars315 opened this issue Jun 30, 2020 · 4 comments

Comments

@mars315
Copy link

mars315 commented Jun 30, 2020

我看了博客和文档,没有指出这么做的原因。希望作者能在百忙之中解答下,非常感谢, @xiaonanln

@synchronized
Copy link

我觉得应该是用来实现服务器之间消息转发,game <=> game,

@tutumagi
Copy link

主要是消息转发,dispatcher 记录了各个entity在哪个gate,在哪个game等等信息

@simonlingoogle
Copy link
Collaborator

有几个好处:

  • 减少game和gate之间的连接数量。game和gate进程的数量需要随着玩家数量和游戏逻辑的复杂性上升而增加。如果每个game都和每个gate建立连接,总的连接数量会很大。而dispatcher的数目相对较少,这样减少了总的连接数目。
  • Dispatcher记录了所有entity在哪个game上,这样entity之间只要拿到ID就可以相互调用RPC。
  • Entity在game之间迁移,或者热更新game进程的时候,dispather可以保证RPC消息的可靠性和有序性。

如果没有dispatcher应该也是可以做到这些的功能,但是会困难一点。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@synchronized @tutumagi @simonlingoogle @mars315 and others