zoukankan      html  css  js  c++  java
  • [原] Unity下的ElectroServer的连接

    ES的版本是5.4.1,示例目录下code_examplesConnectAndLoginManually是Unity的连接和登录代码。

    除了host和port需要指定,在连接时需要指定连接方式,如下第10行指定了BinaryTCP。

     1 void Start () {
     2     log4net.Config.BasicConfigurator.Configure();
     3     
     4     es.Engine.Queueing = EsEngine.QueueDispatchType.External;
     5 
     6     es.Engine.ConnectionResponse += OnConnectionResponse;
     7     es.Engine.LoginResponse += OnLoginResponse;
     8 
     9     Server server = new Server("server1");
    10     AvailableConnection availCon = new AvailableConnection(host, port, AvailableConnection.TransportType.BinaryTCP);
    11     server.AddAvailableConnection(availCon);
    12 
    13     es.Engine.AddServer(server);
    14 
    15     Security.PrefetchSocketPolicy(host, port);
    16 
    17     es.Engine.Connect();
    18 }

    其它可选项是:

    AvailableConnection.TransportType.BinaryHTTP
    AvailableConnection.TransportType.BinaryTCP
    AvailableConnection.TransportType.BinaryUDP

    连接方式对应的端口在AdminTool的Server Management中定义。 如下配置中,如果使用BinaryTCP,端口号是9898。

  • 相关阅读:
    KVC的取值和赋值
    OC中属性的内存管理
    mysql的通信协议
    Proactor模式&Reactor模式详解
    Linux异步IO学习
    Redis 分布式锁的实现原理
    redis过期键
    智能指针
    std::unique_lock与std::lock_guard
    手撕代码
  • 原文地址:https://www.cnblogs.com/basecn/p/es_start.html
Copyright © 2011-2022 走看看