コード例 #1
0
        public NetworkConnection(Socket socket, CancellationToken disconnectToken = default)
        {
            _socket = socket;
            _disconnectTokenSource = CancellationTokenSource.CreateLinkedTokenSource(disconnectToken);

            _pipe = new DxSocketPipe(_socket, _disconnectTokenSource.Token);

            // Get IP Address
            IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;

            if (endPoint != null)
            {
                IpAddress = endPoint.Address.ToString();
            }
        }
コード例 #2
0
ファイル: DxPipeLine.cs プロジェクト: sybrenw/latticecraft
        public DxPipeLine(params IDxPipe[] pipes)
        {
            _pipes = pipes.ToList();

            IDxPipe p = null;

            foreach (var pipe in pipes)
            {
                if (p != null)
                {
                    pipe.ConnectPipe(p);
                }

                p = pipe;
            }

            _outputPipe = p;
        }
コード例 #3
0
        public async Task ConnectAsync(string ip, int port)
        {
            do
            {
                _socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
                while (!Connected && !_disconnectTokenSource.IsCancellationRequested)
                {
                    try
                    {
                        await _socket.ConnectAsync(ip, port);

                        Logger.LogInformation("Connected to: {0}", ip);
                        _pipe = new DxSocketPipe(_socket, _disconnectTokenSource.Token);
                        break;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Failed to connect: {0}", ex);
                        await Task.Delay(5000);
                    }
                }
                await RunAsync();
            } while (!_disconnectTokenSource.IsCancellationRequested && KeepAlive);
        }
コード例 #4
0
ファイル: DxPipeLine.cs プロジェクト: sybrenw/latticecraft
 public void ConnectPipe(IDxPipe source)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 public void ConnectPipe(IDxPipe source)
 {
     _source = source;
 }