Ejemplo n.º 1
0
        private IEnumerable <byte> CommandHandler(IEnumerable <byte> received)
        {
            SafeExecution.TryCatch(() => CommandHandlerInternal(received),
                                   exception => _recorder.DefaultException(this, exception));

            return(Enumerable.Empty <byte>());
        }
Ejemplo n.º 2
0
 private void RecordReceivedHandler(string value)
 {
     if (Activated)
     {
         SafeExecution.TryCatch(() => TrySendText(value),
                                exception => _recorder.DefaultException(this, exception));
     }
 }
Ejemplo n.º 3
0
 private void ConnectedHandler(string address)
 {
     SafeExecution.TryCatch(() =>
     {
         _remoteTraceMonitorСonsistent.SetPrompt(address);
         _remoteTraceMonitorСonsistent.ClearTextBox();
     },
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 4
0
        private async Task OpenInternal()
        {
            _isOpened = true;
            _recorder.RecordInfo(nameof(NetworkPoint), $"NetworkPoint opened {(_sListener.LocalEndPoint).Address}:{(_sListener.LocalEndPoint).Port}");

            while (_isOpened)
            {
                _sListener.Listen(10);
                ISocket socket = await _sListener.AcceptAsync();

                SafeExecution.TryCatch(() => ConnectionAcceptedHandler(socket), ExceptionHandler);
            }
        }
Ejemplo n.º 5
0
        private bool TryConnectInternal(INetworkAddress networkAddress, out INetworkTunnel networkTunnel)
        {
            var socket = _socketFactory.Invoke(networkAddress.IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            var isFail = false;

            networkTunnel = default;

            SafeExecution.TryCatch(
                () => socket.Connect(networkAddress.IP, networkAddress.Port),
                e =>
            {
                SafeExecution.TryCatch(() => socket.Dispose(),
                                       e => ExceptionHandler(e));
                isFail = true;
            });

            if (!isFail)
            {
                networkTunnel = _networkTunnelFactory.Invoke(socket);
            }

            return(!isFail);
        }
Ejemplo n.º 6
0
 private void ReceivedHandler(byte[] receivedBytes)
 {
     SafeExecution.TryCatch(() => ReceivedHandlerInternal(receivedBytes), ExceptionHandler);
 }
Ejemplo n.º 7
0
 public void Send(IEnumerable <byte> data)
 {
     SafeExecution.TryCatch(() => SendInternal(data), ExceptionHandler);
 }
Ejemplo n.º 8
0
 public void Response(IEnumerable <byte> data)
 {
     SafeExecution.TryCatch(() => ResponseInternal(data), ExceptionHandler);
 }
Ejemplo n.º 9
0
 public void ActivateAndSendCache()
 {
     SafeExecution.TryCatch(() => ActivateAndSendCacheInternal(),
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 10
0
 public void Start()
 {
     SafeExecution.TryCatch(() => _autoLocalConnector.Start(),
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 11
0
 public void RegisterCommand(string name, Action handler, string description = "")
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterCommand(name, handler, description),
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 12
0
 public void Send(byte[] data)
 {
     RecordSendInfo($"Tunnel.Send {data.Length}");
     SafeExecution.TryCatch(() => _socket.Send(data), ExceptionHandler);
 }
Ejemplo n.º 13
0
 private void Bind(IPAddress ipAddress, int port)
 {
     SafeExecution.TryCatch(() => _sListener.Bind(ipAddress, port),
                            ExceptionHandler);
 }
Ejemplo n.º 14
0
 private void AcceptedHandler(INetworkTunnel tunnel)
 {
     SafeExecution.TryCatch(() => AcceptedHandlerInternal(tunnel), ExceptionHandler);
 }
Ejemplo n.º 15
0
 public void RegisterCommandWithParameters(string name, Action <IEnumerable <string> > handler, string description = "")
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterCommandWithParameters(name, handler, description),
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 16
0
 private void TextReceivedHandler(string value)
 {
     SafeExecution.TryCatch(() => _remoteTraceMonitorСonsistent.DisplayNextMessage(value),
                            exception => _recorder.DefaultException(this, exception));
 }
Ejemplo n.º 17
0
 public void RegisterWrongCommandHandler(Action action)
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterWrongCommandHandler(action),
                            exception => _recorder.DefaultException(this, exception));
 }