public ClientInvocatorContext(Type invocator, string connectorName, string hostAddress,
                                      WebSocketSupportedSchemes scheme = WebSocketSupportedSchemes.WS,
                                      string uriPath = "",
                                      string query   = "",
                                      Func <WebSocket, Task> onConnectedAsync    = null,
                                      Func <WebSocket, Task> onDisconnectedAsync = null)
            : base(invocator)
        {
            ConnectorName = connectorName ?? throw new ArgumentNullException(nameof(connectorName));
            HostAddress   = hostAddress ?? throw new ArgumentNullException(nameof(hostAddress));
            Scheme        = scheme;
            UriPath       = uriPath;
            Query         = query;

            OnConnectedAsync    = onConnectedAsync;
            OnDisconnectedAsync = onDisconnectedAsync;

            var schemeStr  = Scheme == WebSocketSupportedSchemes.WS ? "ws" : "wss";
            var uriBuilder = new UriBuilder(new Uri($"{schemeStr}://{HostAddress}"));

            if (!string.IsNullOrEmpty(UriPath))
            {
                uriBuilder.Path = UriPath;
            }

            if (!string.IsNullOrEmpty(Query))
            {
                uriBuilder.Query = Query;
            }

            Uri          = uriBuilder.Uri;
            ConnectorKey = $"{ConnectorName}|{HostAddress}|{Invocator.GetHashCode()}";
        }
示例#2
0
        public ConnectorHostPair(string connectorname, string hostAddress, Type invocator)
        {
            ConnectorName = connectorname ?? throw new ArgumentNullException(nameof(connectorname));
            HostAddress   = hostAddress ?? throw new ArgumentNullException(nameof(hostAddress));
            Invocator     = invocator ?? throw new ArgumentNullException(nameof(invocator));

            Key = $"{ConnectorName}|{HostAddress}|{Invocator.GetHashCode()}";
        }
示例#3
0
 public SocketsOptions()
 {
     Invocator             = typeof(TInvocator);
     InvocatorTypeHashCode = Invocator.GetHashCode();
 }