Exemplo n.º 1
0
        private void OnDataReceived(TcpFrameArrivedEventArgs message)
        {
            var deserialized = _objectSerializerService.Deserialize(message.FrameData);

            switch (deserialized)
            {
            case ISignalingMessage signalingMessage:
            {
                var args = new MessageReceivedEventArgs
                {
                    Message = signalingMessage
                };
                MessageReceived?.Invoke(this, args);
                break;
            }

            case RowInfo rowInfo:
            {
                var args = new RowInfoReceivedEventArgs
                {
                    RowInfo = rowInfo
                };
                RowInfoReceived?.Invoke(this, args);
                break;
            }
            }
        }
Exemplo n.º 2
0
        private void OnDataReceived(TcpFrameArrivedEventArgs message)
        {
            var args = new MessageReceivedEventArgs {
                Message = (ISignalingMessage)_objectSerializerService.Deserialize(message.FrameData)
            };

            MessageReceived?.Invoke(this, args);
        }
Exemplo n.º 3
0
        private void OnRowInfoReceived(object sender, Message message)
        {
            var args = new RowInfoReceivedEventArgs {
                RowInfo = (RowInfo)_objectSerializerService.Deserialize(message.Data)
            };

            RowInfoReceived?.Invoke(this, args);
        }
Exemplo n.º 4
0
        public async void StartListening(string ip, int port)
        {
            var server = new AsyncNetTcpServer(port);

            server.ServerStarted += (s, e) => Console.WriteLine($"Server started on port: " +
                                                                $"{e.ServerPort}");
            server.ConnectionEstablished += (s, e) =>
            {
            };
            server.FrameArrived += (s, e) =>
            {
                var message = _objectSerializerService.Deserialize(e.FrameData);

                switch (message)
                {
                case string init:
                {
                    var parts = init.Split(' ');
                    _logService.LogInfo($"Connected with {parts[1]}");

                    if (parts[1].StartsWith("CCRC"))
                    {
                        _domainCcrcName = parts[1];
                    }
                    else if (parts[1].StartsWith("NCC"))
                    {
                        _secondNccName = parts[1];
                    }
                    AddToTranslationDictionary(e.RemoteTcpPeer, parts);
                    break;
                }

                case ISignalingMessage signalingMessage:
                {
                    ProcessMessage(signalingMessage);
                    break;
                }
                }
            };
            await server.StartAsync(CancellationToken.None);
        }
Exemplo n.º 5
0
        private void OnDataReceived(TcpFrameArrivedEventArgs message)
        {
            var deserialized = _objectSerializerService.Deserialize(message.FrameData);

            if (deserialized is EonPacket eonPacket)
            {
                var args = new PackageReceivedEventArgs {
                    Packet = eonPacket
                };
                PackageReceived?.Invoke(this, args);
            }
            else if (deserialized is ISignalingMessage signalingMessage)
            {
                var args = new MessageReceivedEventArgs {
                    Message = signalingMessage
                };
                MessageReceived?.Invoke(this, args);
            }
        }
        public async void StartListening()
        {
            var server = new AsyncNetTcpServer(CableCloudConfig.Port);

            server.ServerStarted += (s, e) => Console.WriteLine($"Server started on port: " +
                                                                $"{e.ServerPort}");
            server.ConnectionEstablished += (s, e) =>
            {
            };
            server.FrameArrived += (s, e) =>
            {
                var message = _objectSerializerService.Deserialize(e.FrameData);

                switch (message)
                {
                case string init:
                {
                    var parts = init.Split(' ');
                    _logService.LogInfo($"Connected with {parts[1]}");

                    if (parts[1].StartsWith("CCRC"))
                    {
                        _ccrcList.Add(parts[1]);
                    }
                    AddToTranslationDictionary(e.RemoteTcpPeer, parts);
                    break;
                }

                case ISignalingMessage signalingMessage:
                {
                    ProcessMessage(e, signalingMessage);
                    break;
                }

                case EonPacket eonPacket:
                {
                    ProcessPackage(e.RemoteTcpPeer, eonPacket);
                    break;
                }
                }
            };
            await server.StartAsync(CancellationToken.None);
        }