Beispiel #1
0
        public static void RegisterSocketClient(string host, int port, int index, bool islittleEnd)
        {
            if (clients == null)
            {
                return;
            }
            if (index < 0 || index >= clients.Length)
            {
                Debugger.LogError("connect index is invalid->" + index + "^" + clients.Length);
                return;
            }

            {
                NetClient netClient = clients[index];
                if (netClient == null)
                {
                    netClient      = NetClient.GenNetClient();
                    clients[index] = netClient;
                }
                if (netClient.IsSocketOK())
                {
                    netClient.Close();
                }
                clients[index].Init(host, port, index, islittleEnd);
            }
        }
Beispiel #2
0
        public static void Init(int num)
        {
            NetMsgPool.Init(1024 * 1024 * 4);
            if (clients != null)
            {
                for (int i = 0; i < clients.Length; i++)
                {
                    if (clients[i] != null)
                    {
                        clients[i].Close();
                    }
                }
            }

            clients = new NetClient[num];

            for (int i = 0; i < num; i++)
            {
                clients[i] = NetClient.GenNetClient();
            }
        }