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