public override AChannel ConnectChannel(string address) { ClientWebSocket webSocket = new ClientWebSocket(); WChannel channel = new WChannel(webSocket, this); this.channels[channel.Id] = channel; channel.ConnectAsync(address).Coroutine(); return(channel); }
public async ETVoid StartAccept(IEnumerable <string> prefixs) { try { foreach (string prefix in prefixs) { this.httpListener.Prefixes.Add(prefix); } httpListener.Start(); while (true) { try { HttpListenerContext httpListenerContext = await this.httpListener.GetContextAsync(); HttpListenerWebSocketContext webSocketContext = await httpListenerContext.AcceptWebSocketAsync(null); WChannel channel = new WChannel(webSocketContext, this); this.channels[channel.Id] = channel; this.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); } }