public IBinaryConnection Create(BinaryConnectionConfig config, IMessageValidator validator)
        {
            IBinaryConnection connection = null;

            if (config is TcpClientConfig)
            {
                connection = new TcpClientConnection(validator)
                {
                    Logger = _logger
                }
            }
            ;

            if (config is TcpListenerConfig)
            {
                connection = new TcpListenerConnection(validator)
                {
                    Logger = _logger
                }
            }
            ;

            connection?.Initialize(config);

            return(connection);
        }
Example #2
0
 protected internal WSConnection(
     IConnectionManager manager,
     Endpoint endpoint,
     IBinaryConnection connection,
     IConnector?connector,
     string connectionId,
     ObjectAdapter?adapter)
     : base(manager, endpoint, connection, connector, connectionId, adapter)
 {
 }
Example #3
0
        private void OnAddConnection(IBinaryConnection binaryConnection)
        {
            var deviceGatewayService = new DeviceGatewayService(binaryConnection, this);

            _deviceGatewayServicesByConnection.Add(binaryConnection, deviceGatewayService);

            if (IsStarted)
            {
                deviceGatewayService.Start();
            }
        }
Example #4
0
        private void OnRemoveConnection(IBinaryConnection binaryConnection)
        {
            DeviceGatewayService deviceGatewayService;

            if (!_deviceGatewayServicesByConnection.TryGetValue(binaryConnection, out deviceGatewayService))
            {
                binaryConnection.Dispose();
            }
            else
            {
                var deviceGuid = deviceGatewayService.DeviceGuid;
                if (deviceGuid != Guid.Empty)
                {
                    _deviceService.UnsubscribeFromCommands(deviceGuid.ToString(), deviceGatewayService.DeviceKey);
                    _deviceGatewayServicesByDevice.Remove(deviceGuid);
                }

                deviceGatewayService.Stop();
            }

            _deviceGatewayServicesByConnection.Remove(binaryConnection);
        }
 /// <summary>
 /// Initialize new instance of <see cref="BinaryServiceBase"/>
 /// </summary>
 protected BinaryServiceBase(IBinaryConnection connection)
 {
     _connection = connection;
     _messageReaderWriter = new MessageReaderWriter(connection);
     _logger = LogManager.GetLogger(GetType());            
 }        
Example #6
0
 public MessageReaderWriter(IBinaryConnection connection)
 {
     _connection = connection;
 }
 public void Destroy(IBinaryConnection instance)
 {
 }
 /// <summary>
 /// Initialize new instance of <see cref="BinaryServiceBase"/>
 /// </summary>
 protected BinaryServiceBase(IBinaryConnection connection)
 {
     _connection          = connection;
     _messageReaderWriter = new MessageReaderWriter(connection);
     _logger = LogManager.GetLogger(GetType());
 }
 public BinaryServiceHelper(IBinaryConnection connection)
     : base(connection)
 {
     _cmdId = 0;
     _cmdData = new Dictionary<int, TaskCompletionSource<CommandResult>>();
 }
 public MessageReaderWriter(IBinaryConnection connection)
 {
     _connection = connection;
 }
Example #11
0
 public DeviceGatewayService(IBinaryConnection connection, GatewayService gatewayService) :
     base(connection)
 {
     _gatewayService = gatewayService;
 }
 public BinaryServiceHelper(IBinaryConnection connection)
     : base(connection)
 {
     _cmdId   = 0;
     _cmdData = new Dictionary <int, TaskCompletionSource <CommandResult> >();
 }