public DefaultConnectedClientFactory(
     IUpdateDetector updateDetector,
     IConnectionGroupProvider connectionGroupProvider)
 {
     _updateDetector          = updateDetector;
     _connectionGroupProvider = connectionGroupProvider;
 }
 public ConnectInitializer(
     IUpdateDetector updateDetector,
     IEnumerable <IConnectHook> connectHooks)
 {
     _updateDetector = updateDetector;
     _connectHooks   = connectHooks;
 }
 public EngageConnectionInitializer(
     ICombatRoomStore combatRoomStore,
     IUpdateDetector updateDetector)
 {
     _combatRoomStore = combatRoomStore;
     _updateDetector  = updateDetector;
 }
Exemple #4
0
 public ConnectionInitializer(
     IUpdateDetector updateDetector,
     IPlayerRepository playerRepository)
 {
     _updateDetector   = updateDetector;
     _playerRepository = playerRepository;
 }
        public async Task ShouldSetUpdateDetector(
            [Frozen] IUpdateDetector updateDetector,
            AnonymousConnectionInitializer sut)
        {
            var client = await sut.ConnectAsync(Create <IConnection>(), Cts.Token);

            Assert.Equal(updateDetector, GetPrivateField(client, "_updateDetector"));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectedClient"/> class.
 /// Sets the single group of the client.
 /// </summary>
 /// <param name="clientId">Unique connected client identity. There
 /// should be no any clients connected at the same time with the same
 /// identity.</param>
 /// <param name="connection">Client's connection.</param>
 /// <param name="updateDetector">Update detector for marking groups for
 /// update when the group changes.</param>
 /// <param name="group">Messaging group where the client is placed initially.</param>
 public ConnectedClient(
     string clientId,
     IConnection connection,
     IUpdateDetector updateDetector,
     string group)
     : this(clientId, connection, updateDetector)
 {
     _groups = new(new[] { group });
 }
 public ConnectedClient(
     string clientId,
     IConnection connection,
     IUpdateDetector updateDetector,
     IEnumerable <string> groups)
     : this(clientId, connection, updateDetector)
 {
     _groups = new(groups);
 }
 private ConnectedClient(
     string clientId,
     IConnection connection,
     IUpdateDetector updateDetector)
 {
     ClientId        = clientId;
     Connection      = connection;
     _updateDetector = updateDetector;
 }
Exemple #9
0
    public void ShouldNotMarkForUpdateOnCreation(IUpdateDetector updateDetector)
    {
        _ = new ConnectedClient(
            Create <string>(),
            Create <IConnection>(),
            updateDetector,
            Create <string>());

        Mock.Get(updateDetector).Verify(x => x.MarkForUpdate(It.IsAny <IEnumerable <string> >()), Times.Never);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectedClient"/> class.
 /// </summary>
 /// <param name="clientId">Unique connected client identity. There
 /// should be no any clients connected at the same time with the same
 /// identity.</param>
 /// <param name="connection">Client's connection.</param>
 /// <param name="group">Messaging group where the client is placed initially.</param>
 /// <param name="updateDetector">Update detector for marking groups for
 /// update when the group changes.</param>
 public ConnectedClient(
     string clientId,
     IConnection connection,
     string group,
     IUpdateDetector updateDetector)
 {
     ClientId        = clientId;
     Connection      = connection;
     _group          = group;
     _updateDetector = updateDetector;
 }
        public async Task ShouldSetUpdateDetector(
            [Frozen] IUpdateDetector updateDetector,
            ConnectInitializer sut)
        {
            var client = await sut.ConnectAsync(_validConnection, Cts.Token);

            Assert.Equal(updateDetector, GetPrivateField(client, "_updateDetector"));

            client.Group = "new";
            Mock.Get(updateDetector).Verify(x => x.MarkForUpdate("new"));
        }
Exemple #12
0
    public void ShouldBeCreatedUsingConstructor(
        string clientId,
        IConnection connection,
        string group,
        IUpdateDetector updateDetector)
    {
        var client = new ConnectedClient(clientId, connection, updateDetector, group);

        Assert.Equal(clientId, client.ClientId);
        Assert.Equal(connection, client.Connection);
        Assert.Equal(group, client.Group);
        Assert.Equal(updateDetector, GetPrivateField(client, "_updateDetector"));
    }
 public ConnectionHandler(
     ILogger <ConnectionHandler> logger,
     IConnectionInitializer connectionInitializer,
     IConnectedClientStore connectedClients,
     IMessageDispatcher messageDispatcher,
     IUpdateDetector updateDetector,
     IUpdater updater)
 {
     _logger = logger;
     _connectionInitializer = connectionInitializer;
     _connectedClients      = connectedClients;
     _messageDispatcher     = messageDispatcher;
     _updateDetector        = updateDetector;
     _updater = updater;
 }
Exemple #14
0
        public async Task ShouldSetConnectionAndUpdateDetector(
            IConnection connection,
            PlayerId playerId,
            [Frozen] IUpdateDetector updateDetector,
            ConnectionInitializer sut)
        {
            var joinMessage = Fixture.Build <Join>()
                              .With(x => x.PlayerId, playerId)
                              .Create();

            Mock.Get(connection).Setup(x => x.ReceiveAsync(Cts.Token))
            .ReturnsAsync(joinMessage);

            var client = await sut.ConnectAsync(connection, Cts.Token);

            Assert.Equal(connection, client.Connection);
            Assert.Equal(updateDetector, GetPrivateField(client, "_updateDetector"));
        }
 public ConnectionHandler(
     ILogger <ConnectionHandler> logger,
     IConnectionInitializer connectionInitializer,
     IConnectedClientStore connectedClients,
     IMessageDispatcher messageDispatcher,
     IQueryDispatcher queryDispatcher,
     IUpdateDetector updateDetector,
     IMessageTypeCache messageTypeCache,
     IEnumerable <IConnectedClientInitializer> connectedClientInitializers,
     IUpdater updater)
 {
     _logger = logger;
     _connectionInitializer       = connectionInitializer;
     _connectedClients            = connectedClients;
     _messageDispatcher           = messageDispatcher;
     _queryDispatcher             = queryDispatcher;
     _updateDetector              = updateDetector;
     _messageTypeCache            = messageTypeCache;
     _connectedClientInitializers = connectedClientInitializers;
     _updater = updater;
 }
Exemple #16
0
 public static void MarkForUpdate(this IUpdateDetector updateDetector, string group)
 {
     updateDetector.MarkForUpdate(EnumerableHelpers.AsEnumerable(group));
 }
 public ClientWithUpdateDetectorBuilder(IUpdateDetector updateDetector)
 {
     _updateDetector = updateDetector;
 }
 public ConnectedClientStore(IUpdateDetector updateDetector)
 {
     _updateDetector = updateDetector;
 }