示例#1
0
        public async void ConnectToNcc(string ip, int port, string nodeName)
        {
            var client = new AsyncNetTcpClient(ip, port);

            client.ConnectionEstablished += (s, e) =>
            {
                _client = e.RemoteTcpPeer;
                Console.WriteLine($"Connected to CableCloud");

                var hello = $"INIT {nodeName}";
                var bytes = _objectSerializerService.Serialize(hello);
                _client.Post(bytes);
            };
            client.FrameArrived += (s, e) =>
            {
                OnDataReceived(e);
                //Console.WriteLine($"Client received: " +
                //                  $"{System.Text.Encoding.UTF8.GetString(e.FrameData)}");
            };
            await client.StartAsync(CancellationToken.None);

            //_client = new SimpleTcpClient();
            //_client.Connect(ip, port);

            //_logService.LogInfo("Connected to NCC");

            //_client.Write($"INIT {nodeName}");

            //_client.DataReceived += OnDataReceived;
        }
示例#2
0
        public async void ConnectToNcc(string ip, int port, string nodeName)
        {
            var client = new AsyncNetTcpClient(ip, port);

            client.ConnectionEstablished += (s, e) =>
            {
                _client = e.RemoteTcpPeer;
                Console.WriteLine($"Connected to NCC");

                var hello = $"INIT {nodeName}";
                var bytes = _objectSerializerService.Serialize(hello);
                _client.Post(bytes);
            };
            client.FrameArrived += (s, e) =>
            {
                OnDataReceived(e);
            };
            await client.StartAsync(CancellationToken.None);
        }
        private void SendRowInfo(string nodeName, RowInfo rowInfo)
        {
            if (nodeName == null)
            {
                return;
            }

            if (!_socketOfNode.ContainsKey(nodeName))
            {
                _logService.LogWarning($"{nodeName} is not connected");
                return;
            }

            _logService.LogInfo($"Sending {rowInfo.Action} to {nodeName}");

            var handler = _socketOfNode[nodeName];

            var byteData = _objectSerializerService.Serialize(rowInfo);

            handler.Send(byteData);
        }
示例#4
0
 public void Send(EonPacket package)
 {
     _logService.LogInfo($"Sending {package.Content}");
     _client.Post(_objectSerializerService.Serialize(package));
 }
 public void SendPacket(IRemoteTcpPeer handler, EonPacket package)
 {
     handler.Post(_objectSerializerService.Serialize(package));
 }