/// <summary> /// 初始化订阅发送 /// </summary> /// <param name="options"></param> public static void InitializationChannel(WebSocketClientConfig options) { if (_channelInstance == null) { _channelInstance = new WebSocketChannelClient(options); } }
/// <summary> /// 初始化单点发送 /// </summary> /// <param name="options"></param> public static void InitializationClient(WebSocketClientConfig options) { if (_instance == null) { _instance = new WebSocketClient(options); } }
/// <summary> /// 初始化单点发送 /// </summary> /// <param name="options"></param> public static void Initialization(string redisUrl, string WsPath) { if (_instance == null) { WebSocketClientConfig clientConfig = new WebSocketClientConfig { Redis = new CSRedis.CSRedisClient(redisUrl), PathMatch = WsPath }; InitializationClient(clientConfig); InitializationChannel(clientConfig); } }
public WebSocketRpcClient(ISerializer serializer, ILog log, WebSocketClientConfig config) { _config = config; _serializer = serializer; _log = log; _client = new ClientWebSocket(); _client.Options.SetRequestHeader("content-type", _serializer.ContentType); _semaphore = new SemaphoreSlim(1, 1); _responseMap = new ConcurrentDictionary <string, Tuple <Type, TaskCompletionSource <object> > >(); _cancelSource = new CancellationTokenSource(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="configs"></param> public WebSocketBorker(WebSocketClientConfig configs) { if (configs.Redis == null) { throw new ArgumentException("链接参数错误", "Redis"); } if (String.IsNullOrEmpty(configs.PathMatch)) { throw new ArgumentException("参数不能为空", "PathMatch"); } _redis = configs.Redis; _pathMatch = String.IsNullOrEmpty(configs.PathMatch) ? "/ws":configs.PathMatch.Insert(0, @"/"); _appId = configs.PathMatch.Trim('/').Replace('/', '_'); }