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); }
protected internal WSConnection( IConnectionManager manager, Endpoint endpoint, IBinaryConnection connection, IConnector?connector, string connectionId, ObjectAdapter?adapter) : base(manager, endpoint, connection, connector, connectionId, adapter) { }
private void OnAddConnection(IBinaryConnection binaryConnection) { var deviceGatewayService = new DeviceGatewayService(binaryConnection, this); _deviceGatewayServicesByConnection.Add(binaryConnection, deviceGatewayService); if (IsStarted) { deviceGatewayService.Start(); } }
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()); }
public MessageReaderWriter(IBinaryConnection connection) { _connection = connection; }
public void Destroy(IBinaryConnection instance) { }
public BinaryServiceHelper(IBinaryConnection connection) : base(connection) { _cmdId = 0; _cmdData = new Dictionary<int, TaskCompletionSource<CommandResult>>(); }
public DeviceGatewayService(IBinaryConnection connection, GatewayService gatewayService) : base(connection) { _gatewayService = gatewayService; }
public BinaryServiceHelper(IBinaryConnection connection) : base(connection) { _cmdId = 0; _cmdData = new Dictionary <int, TaskCompletionSource <CommandResult> >(); }