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;
 }
示例#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"));
        }
示例#6
0
 /// <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 });
 }
示例#7
0
 public ConnectedClient(
     string clientId,
     IConnection connection,
     IUpdateDetector updateDetector,
     IEnumerable <string> groups)
     : this(clientId, connection, updateDetector)
 {
     _groups = new(groups);
 }
示例#8
0
 private ConnectedClient(
     string clientId,
     IConnection connection,
     IUpdateDetector updateDetector)
 {
     ClientId        = clientId;
     Connection      = connection;
     _updateDetector = updateDetector;
 }
示例#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);
    }
示例#10
0
 /// <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"));
        }
示例#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;
 }
示例#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"));
        }
示例#15
0
 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;
 }
示例#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;
 }