[Turn] Actor frame using ET Reviews

After the study of the past few days, we met with numerous pits, after the owners and the group of eleven chiefs pointing you, forget and understand the use of mechanisms Actor.

Actor is the core of what the framework ET, before using the Actor must understand what is distributed servers, I would like to explain.

Distributed simply say that I have 3 servers together for a game service, then their relationship is:

The first client communication:

The client - authentication server - gateway servers - Authentication Server - Client

Client communications (communications carried out after the first):

Client - Gateway Server - function server (DB, Map server Chat chat servers, etc.) - the gateway server - client

That is all the data are unified transit through the gateway server.

E.g:

A server (authentication account, the gateway server, a location server).

Server B (abbreviated database operations DB).

C servers (Map Server, Chat chat server, etc.).

 

Verify account server (Realm):

 

Verify operation process:

1, to verify the legitimacy of the account (I through the database).

2, find the IP address and port gateway based on the profile, if there is more than just a random distribution (where you can be a load-balancing, for example, to determine the number of gateway server assigned).

3, Gate send data to the server, the request to create a temporary KEY

4, the KEY only 20 seconds, more than just self-destruct, you can define your own duration.

5, the received transmission IP and port KEY plus the Gate server to the client.

 

Gateway Server (create a KEY, this is not to introduce a plug-understand):

The gateway server (the server currently registered on Loaction server):

Operating procedures:

1, first find whether the temporary KEY presence, absence, says it is illegal, I did not write this piece of code.

2, use the Create a Player, and set the ID. And added to PlayerComponent components inside.

3, Actor forwards the message is sent to find the server to which the location of the server by UnitId Player.

4, as PlayerComponent and UnitGateComponent what it is, look at the code it yourself, it is easy to understand.

5, registration Actor forward (when registered, in order to pass this message to other servers server).

6、通过配置文件获取MAP服务器的IP和端口(可能有多个,我就用了一个所以我取了第一个、如果多个可以考虑用每个服务器的最大人数来分配,这个要自己实现了)。

7、向MAP服务器发送创建Actor请求(这块下面会有介绍MAP是怎么操作的)。

8、这里很重要、很重要、很重要(我当初就在这里耽误了很多时间,最我来说是个坑)、MAP服务器会发送一个m2GRegisterActorResponse.ActorId。

9、这个ActorId很重要、是MAP注册到位置服务器的ID,Actor发送消息会通过这个ID来转发到指定服务器的。

10、Actor消息转发是通过Player的UnitId来转发的,所以我把ActorId赋值给Player的UnitId。

 

MAP服务器(接收创建Actor请求):

操作流程:

1、创建一个UNIT,并指定这个是英雄类型的。

2、给UNIT添加ActorComponent并添加位置到位置服务器,这很重要,没有这个是没办法分发消息的。

3、把这个UNIT添加到ActorManagerComponent组件里,我个人理解这个是用来管理该服务器上所有的Actor对象。

4、把生成的UNITID发送出去。

 

总结:

完成以上就可以进行Actor转发了,只需要在MAP服务器先实现不同的Handler就可以。

大家认为的注册到位置服务器,不是注册一个服务器,而是每个对象的注册,比如:A客户端使用Actor,那位置服务器只是注册了A客户端的东西,B客户单使用,就在位置服务器注册B客户端的东西。

Guess you like

Origin www.cnblogs.com/zhangliang111/p/11653163.html