Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        //初始化服务器
        _server = new MicrosoftServer(PLAYER_MAX_COUNT, BUFF_SIZE, OnReceive);
        _server.Init();
        // 获得主机相关信息
        IPAddress[] addressList   = Dns.GetHostEntry(Environment.MachineName).AddressList;
        IPEndPoint  localEndPoint = new IPEndPoint(addressList[addressList.Length - 1], PORT);

        _server.Start(localEndPoint);
        _server.Completed += OnComplete;

        string msg = $"Server is listening at address - {_server.Address}:{_server.Port} ...";

        Debug.Log(msg);
    }
Ejemplo n.º 2
0
 void Awake()
 {
     //初始化服务器
     _server = new MicrosoftServer(PLAYER_MAX_COUNT, BUFF_SIZE, OnReceive);
     _server.Init();
 }