コード例 #1
0
        private IEnumerable <byte> CommandHandler(IEnumerable <byte> received)
        {
            SafeExecution.TryCatch(() => CommandHandlerInternal(received),
                                   exception => _recorder.DefaultException(this, exception));

            return(Enumerable.Empty <byte>());
        }
コード例 #2
0
 private void RecordReceivedHandler(string value)
 {
     if (Activated)
     {
         SafeExecution.TryCatch(() => TrySendText(value),
                                exception => _recorder.DefaultException(this, exception));
     }
 }
コード例 #3
0
 private void ConnectedHandler(string address)
 {
     SafeExecution.TryCatch(() =>
     {
         _remoteTraceMonitorСonsistent.SetPrompt(address);
         _remoteTraceMonitorСonsistent.ClearTextBox();
     },
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #6
0
 private void ReceivedHandler(byte[] receivedBytes)
 {
     SafeExecution.TryCatch(() => ReceivedHandlerInternal(receivedBytes), ExceptionHandler);
 }
コード例 #7
0
 public void Send(IEnumerable <byte> data)
 {
     SafeExecution.TryCatch(() => SendInternal(data), ExceptionHandler);
 }
コード例 #8
0
 public void Response(IEnumerable <byte> data)
 {
     SafeExecution.TryCatch(() => ResponseInternal(data), ExceptionHandler);
 }
コード例 #9
0
 public void ActivateAndSendCache()
 {
     SafeExecution.TryCatch(() => ActivateAndSendCacheInternal(),
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #10
0
 public void Start()
 {
     SafeExecution.TryCatch(() => _autoLocalConnector.Start(),
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #11
0
 public void RegisterCommand(string name, Action handler, string description = "")
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterCommand(name, handler, description),
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #12
0
 public void Send(byte[] data)
 {
     RecordSendInfo($"Tunnel.Send {data.Length}");
     SafeExecution.TryCatch(() => _socket.Send(data), ExceptionHandler);
 }
コード例 #13
0
 private void Bind(IPAddress ipAddress, int port)
 {
     SafeExecution.TryCatch(() => _sListener.Bind(ipAddress, port),
                            ExceptionHandler);
 }
コード例 #14
0
 private void AcceptedHandler(INetworkTunnel tunnel)
 {
     SafeExecution.TryCatch(() => AcceptedHandlerInternal(tunnel), ExceptionHandler);
 }
コード例 #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));
 }
コード例 #16
0
 private void TextReceivedHandler(string value)
 {
     SafeExecution.TryCatch(() => _remoteTraceMonitorСonsistent.DisplayNextMessage(value),
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #17
0
 public void RegisterWrongCommandHandler(Action action)
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterWrongCommandHandler(action),
                            exception => _recorder.DefaultException(this, exception));
 }