コード例 #1
0
            public ClientSession(Socket socket)
            {
                _socket = socket;

                _sender   = new TcpFrameSender(socket);
                _receiver = new TcpFrameReceiver(socket);
                _receiver.MessageReceived += message => MessageReceived?.Invoke(message);
            }
コード例 #2
0
ファイル: TcpFeedClient.cs プロジェクト: buybackoff/Zerio
        public void Stop()
        {
            if (!_isRunning)
            {
                return;
            }

            _isRunning = false;

            _receiver = null;
            _sender   = null;

            _socket.Dispose();
            _socket = null;
        }
コード例 #3
0
ファイル: TcpFeedClient.cs プロジェクト: buybackoff/Zerio
        public void Start(string peerId)
        {
            if (_isRunning)
            {
                throw new InvalidOperationException("Already started");
            }

            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
            {
                NoDelay = true
            };

            _socket.Connect(_serverEndpoint);

            _sender   = new TcpFrameSender(_socket);
            _receiver = new TcpFrameReceiver(_socket);
            _receiver.MessageReceived += OnMessageReceived;

            _isRunning = true;

            _receiver.StartReceive();

            Connected?.Invoke();
        }