public static NetPeer Create(IPEndPoint ep, NetworkType netType) { var obj = new NetPeer(); obj.ConnId = Basic.GenID32FromName(ep.ToString()); obj.netType = netType; if (netType == NetworkType.TCP) { if (!obj.InitTcpClient(ep)) { return(null); } } else { if (!obj.InitKcpClient(ep)) { return(null); } } return(obj); }
public static NetPeer Create(uint connId, IPEndPoint addr, NetworkType netType) { var obj = new NetPeer(); obj.ConnId = connId; obj.netType = netType; if (netType == NetworkType.TCP) { if (!obj.InitTcpClient(connId, addr)) { return(null); } } else { if (!obj.InitKcpClient(connId, addr)) { return(null); } } return(obj); }