//public IMessageDispatcher MessageDispatcher { get; set; } /* * public NetworkRoot(NetworkProtocol networkProtocol, ChannelType channelType,string StrIpEndPoint) * { * m_NetworkProtocol = networkProtocol; * m_ChannelType = channelType; * m_StrIpEndPoint = StrIpEndPoint; * }*/ public override bool Init() { if (m_ChannelType == ChannelType.Connect) { switch (m_NetworkProtocol) { case NetworkProtocol.KCP: this.m_AService = new KService(); break; case NetworkProtocol.TCP: this.m_AService = new TService(Packet.PacketSizeLength2); break; case NetworkProtocol.WebSocket: this.m_AService = new WService(); break; } } else { try { IPEndPoint ipEndPoint; switch (m_NetworkProtocol) { case NetworkProtocol.KCP: ipEndPoint = NetHelper.ToIPEndPoint(m_StrIpEndPoint); this.m_AService = new KService(ipEndPoint, this.OnAccept); break; case NetworkProtocol.TCP: ipEndPoint = NetHelper.ToIPEndPoint(m_StrIpEndPoint); this.m_AService = new TService(Packet.PacketSizeLength2, ipEndPoint, this.OnAccept); break; case NetworkProtocol.WebSocket: string[] prefixs = m_StrIpEndPoint.Split(';'); this.m_AService = new WService(prefixs, this.OnAccept); break; } this.m_AService.DisConnectedCallback += OnDisConnected; } catch (Exception e) { throw new Exception($"NetworkComponent Awake Error {m_StrIpEndPoint}", e); } } return(base.Init()); }
public override AChannel ConnectChannel(string address) { IPEndPoint ipEndPoint = NetHelper.ToIPEndPoint(address); return(this.ConnectChannel(ipEndPoint)); }