Exemplo n.º 1
0
        public void Connect(string ip, ushort port)
        {
            if (Connected)
            {
                throw new ProtocolException("Connection error: Already connected to server.");
            }

            // -- Connect to server.
            _stream.Connect(ip, port);

            // -- Begin data reading.
            if (_readTask != null && _readTask.Status == TaskStatus.Running)
            {
                throw new ProtocolException("Connection error: Task already running.");
            }
            else
            {
                _readTask = Task.Factory.StartNew(ReadCycle);
            }
        }