Пример #1
0
        void OnEnable()
        {
            Instance = this;

            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                _socket.Connect(ServerIp, ServerPort);
                _socket.BeginReceive(_receiveBuffer, 0, _receiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveData), null);
            }
            catch (SocketException ex)
            {
                Debug.Log(ex.Message);
            }
        }
        void OnEnable()
        {
            Instance = this;

            _queuedCommands = Queue.Synchronized(new Queue());
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                _socket.Connect(ServerIp, ServerPort);
                _socket.BeginReceive(_receiveBuffer, 0, _receiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveData), null);
            }
            catch (SocketException ex)
            {
                Debug.Log(ex.Message);
            }
        }