Exemplo n.º 1
0
        public IntradomainChannel(IntradomainEndpoint endpoint,
                                  IMessageSerializer serializer,
                                  ChannelSettings channelSettings = null,
                                  IntradomainConnectionSettings connectionSettings = null,
                                  ISecurityWrapper clientSecurityWrapper           = null)
            : this(endpoint, SocketType.Client, serializer)
        {
            _connectionSettings = connectionSettings ?? IntradomainConnectionSettingsBuilder.GetDefaultSettings();
            MaxMessageLength    = channelSettings?.MaxMessageLength ?? ChannelSettings.GetDefault().MaxMessageLength;

            SecurityWrapper = clientSecurityWrapper;
        }
Exemplo n.º 2
0
        internal IntradomainChannel(IntradomainSocket socket,
                                    IMessageSerializer serializer,
                                    ChannelSettings channelSettings = null,
                                    IntradomainConnectionSettings connectionSettings = null,
                                    ISecurityWrapper serverSecurityWrapper           = null)
            : this(socket, serializer)
        {
            _connectionSettings = connectionSettings ?? IntradomainConnectionSettingsBuilder.GetDefaultSettings();
            MaxMessageLength    = channelSettings?.MaxMessageLength ?? ChannelSettings.GetDefault().MaxMessageLength;

            SecurityWrapper = serverSecurityWrapper;
        }
        public bool Connect(IntradomainSocket socket, IntradomainConnectionSettings connectionSettings = null)
        {
            if (string.IsNullOrEmpty(socket.Hub))
            {
                return(false);
            }

            if (socket.Type != SocketType.Client)
            {
                throw new ArgumentException(nameof(socket));
            }

            Func <IntradomainSocket, IntradomainSocket> getSocketData;

            lock (_locker)
            {
                if (!_listeners.ContainsKey(socket.Hub))
                {
                    return(false);
                }

                getSocketData = _listeners[socket.Hub];
            }
            socket.ConnectionId = Guid.NewGuid().ToString();
            var remoteSocket = getSocketData(socket);

            if (remoteSocket == null)
            {
                return(false);
            }

            lock (_locker)
            {
                var connection = new IntradomainConnetcion(remoteSocket,
                                                           socket,
                                                           connectionSettings ?? IntradomainConnectionSettingsBuilder.GetDefaultSettings())
                {
                    ClientSocketState = IntradomainSocketState.Connected
                };

                _connections.Add(socket.ConnectionId, connection);
                _connectionCreated.Set();
                return(true);
            }
        }
Exemplo n.º 4
0
        internal static IntradomainChannel <TMessage> CreateAndOpen <TMessage>(AutoResetEvent channelCreatedEvent,
                                                                               IntradomainSocket socket,
                                                                               IMessageSerializer serializer,
                                                                               ChannelSettings channelSettings = null,
                                                                               IntradomainConnectionSettings connectionSettings = null,
                                                                               ISecurityWrapper serverSecurityWrapper           = null)
            where TMessage : IMessage
        {
            var result = new IntradomainChannel <TMessage>(socket, serializer, channelSettings, connectionSettings, serverSecurityWrapper);

            EstablishConnection(result, channelCreatedEvent, socket, connectionSettings?.ConnectTimeout ?? IntradomainConnectionSettingsBuilder.GetDefaultSettings().ConnectTimeout);
            return(result);
        }