public void CreateProtobufConnection_ShouldCreateWithProperDependencies(
        [Frozen] IProtobufFieldNumberCache cache,
        [Frozen] IProtobufStreamSerializer protobuf,
        [Frozen] IMessageSerializer serializer,
        [Frozen] IMessageTypeCache messageTypeCache,
        [Frozen] IMessageMetadataFactory metadataFactory,
        Stream stream,
        ProtobufConnectionFactory sut)
    {
        var connection = sut.CreateProtobufConnection(stream);

        Assert.IsType <MessageSerializerConnection>(connection);

        Assert.Equal(serializer, GetPrivateField(connection, "_serializer"));
        Assert.Equal(messageTypeCache, GetPrivateField(connection, "_messageTypeCache"));
        Assert.Equal(metadataFactory, GetPrivateField(connection, "_metadataFactory"));

        var rawConnection = GetPrivateField(connection, "_connection") !;

        Assert.NotNull(rawConnection);
        Assert.IsType <ProtobufConnection>(rawConnection);

        Assert.Equal(cache, GetPrivateField(rawConnection, "_fieldNumberCache"));
        Assert.Equal(stream, GetPrivateField(rawConnection, "_stream"));
        Assert.Equal(protobuf, GetPrivateField(rawConnection, "_protobuf"));
    }
 public SignalRConnectionFactory(
     IMessageSerializer messageSerializer,
     IMessageTypeCache messageTypeCache,
     IMessageMetadataFactory clientToServerMessageMetadataFactory)
 {
     _messageSerializer      = messageSerializer;
     _messageTypeCache       = messageTypeCache;
     _messageMetadataFactory = clientToServerMessageMetadataFactory;
 }
 public MessageSerializerConnection(
     IConnection connection,
     IMessageSerializer serializer,
     IMessageTypeCache messageTypeCache,
     IMessageMetadataFactory metadataFactory)
 {
     _connection       = connection;
     _serializer       = serializer;
     _messageTypeCache = messageTypeCache;
     _metadataFactory  = metadataFactory;
 }
예제 #4
0
 /// <summary>
 /// Converts received <see cref="MessageData"/> objects to the actual messages,
 /// and converts actual messages to <see cref="MessageData"/> before sending.
 /// Attaches required metadata to objects before sending.
 /// </summary>
 public static IConnection AddCoreMessageSerialization(
     this IConnection connection,
     IMessageSerializer messageSerializer,
     IMessageTypeCache messageTypeCache,
     IMessageMetadataFactory messageMetadataFactory)
 {
     return(new MessageSerializerConnection(
                connection,
                messageSerializer,
                messageTypeCache,
                messageMetadataFactory));
 }
예제 #5
0
    public ProtobufConnectionFactory(
        IProtobufFieldNumberCache fieldNumberCache,
        IProtobufStreamSerializer protobuf,
        IMessageSerializer messageSerializer,
        IMessageTypeCache messageTypeCache,
        IMessageMetadataFactory messageMetadataFactory)
    {
        _fieldNumberCache = fieldNumberCache;
        _protobuf         = protobuf;

        _messageSerializer      = messageSerializer;
        _messageTypeCache       = messageTypeCache;
        _messageMetadataFactory = messageMetadataFactory;
    }
    public void ShouldWrapConnectionInMessageSerializerConnection(
        IConnection connection,
        IMessageSerializer messageSerializer,
        IMessageTypeCache messageTypeCache,
        IMessageMetadataFactory messageMetadataFactory)
    {
        var sut = connection.AddCoreMessageSerialization(
            messageSerializer, messageTypeCache, messageMetadataFactory);

        Assert.IsType <MessageSerializerConnection>(sut);
        Assert.Equal(connection, GetPrivateField(sut, "_connection"));
        Assert.Equal(messageSerializer, GetPrivateField(sut, "_serializer"));
        Assert.Equal(messageTypeCache, GetPrivateField(sut, "_messageTypeCache"));
        Assert.Equal(messageMetadataFactory, GetPrivateField(sut, "_metadataFactory"));
    }
예제 #7
0
 public MessageProcessor(
     ILogger <MessageProcessor> logger,
     IClientConnectionFactory connectionFactory,
     IMessageDispatcher dispatcher,
     IProfileTokenProvider profileTokenProvider,
     IMessageMetadataFactory metadataFactory,
     IMessageTypeCache messageTypeCache,
     IAuthenticationService authenticationService)
 {
     _logger                = logger;
     _connectionFactory     = connectionFactory;
     _dispatcher            = dispatcher;
     _profileTokenProvider  = profileTokenProvider;
     _metadataFactory       = metadataFactory;
     _messageTypeCache      = messageTypeCache;
     _authenticationService = authenticationService;
 }