ET框架---NetInnerComponent学习笔记

NetInnerComponent

请大家关注我的微博:@NormanLin_BadPixel坏像素


我们在LocationProxyComponent学习笔记有简单介绍过NetInnerComponent,在那里我们介绍了NetInnerComponent的一些变量和方法。不过我们忘记了还有热更层的程序集,在热更的程序集里,还有NetInnerComponent的扩展方法。

NetInnerComponentAwakeSystem

在这里,我们看到,NetInnerComponent注册了2个Awake方法,无参数和带IPEndPoint参数的。并且注册了Update方法。

public static class NetInnerComponentEx
{
    public static void Awake(this NetInnerComponent self)
    {
        self.Awake(NetworkProtocol.TCP);
        self.MessagePacker = new MongoPacker();
        self.MessageDispatcher = new InnerMessageDispatcher();
        self.AppType = self.Entity.GetComponent<StartConfigComponent>().StartConfig.AppType;
    }

    public static void Awake(this NetInnerComponent self, IPEndPoint ipEndPoint)
    {
        self.Awake(NetworkProtocol.TCP, ipEndPoint);
        self.MessagePacker = new MongoPacker();
        self.MessageDispatcher = new InnerMessageDispatcher();
        self.AppType = self.Entity.GetComponent<StartConfigComponent>().StartConfig.AppType;
    }

    public static void Update(this NetInnerComponent self)
    {
        self.Update();
    }
}

我们看到,这里设置了NetInnerComponent的消息打包工具跟消息分发器。并且设置了AppType

看到InnerMessageDispatcher,大家或许都晕了。怎么有那么多种的消息调度器。

又是InnerMessageDispatcher

又是OuterMessageDispatcher

又是MessageDispatherComponent

又是ActorMessageDispatherComponent的。

还有热更层的MessageDispatherComponentHotfixMessageDispatcher

到底什么用呦。

这里我简单给打家分一下,让大家不至于太乱。

首先,MessageDispatherComponentActorMessageDispatherComponent都是公共的组件,只不过处理的消息不同,前者处理普通的消息,后者处理Actor消息,因为Actor消息只会在服务器之间发送,所以ActorMessageDispatherComponent只会添加到服务端上,而客户端是没有的。

OuterMessageDispatcher,我们可以理解为是客户端与服务器通信的消息分发器。因为两者互传,所以两者都有。而热更层的HotfixMessageDispatcher,则是在客户端分发热更相关消息的时候会额外经过HotfixMessageDispatcher

那不同服务所在服务器之间的通信消息又是用什么调度的呢?这个时候就用到了我们的InnerMessageDispatcher啦。而InnerMessageDispatcher最后会把Actor消息传给ActorMessageDispatherComponent里面处理。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值