public override BaseChannel ConnectChannel(string address) { var webSocket = new ClientWebSocket(); var channel = new WChannel(webSocket, this); IdChannels[channel.Id] = channel; channel.ConnectAsync(address).Forget(); return(channel); }
private async UniTaskVoid AcceptAsync(IEnumerable <string> prefixes) { try { foreach (var prefix in prefixes) { _httpListener.Prefixes.Add(prefix); } _httpListener.Start(); while (true) { try { var httpListenerContext = await _httpListener.GetContextAsync(); var webSocketContext = await httpListenerContext.AcceptWebSocketAsync(null); var channel = new WChannel(webSocketContext, this); IdChannels[channel.Id] = channel; OnAccept(channel); } catch (Exception e) { Log.Error(e); } } } catch (HttpListenerException e) { if (e.ErrorCode == 5) { throw new Exception($"CMD管理员中输入: netsh http add urlacl url=http://*:8080/ user=Everyone", e); } Log.Error(e); } catch (Exception e) { Log.Error(e); } }