/// <summary> /// 使用预先设置的数据连接网络频道。 /// </summary> /// <param name="name">网络频道名称。</param> /// <param name="hostOrIPString">远程主机的名称或 IP 地址字符串。</param> /// <param name="port">远程主机的端口号。</param> /// <param name="userData">用户自定义数据。</param> public void ConnectNetworkChannel(string name, string hostOrIPString, int port, object userData) { if (string.IsNullOrEmpty(hostOrIPString)) { Log.Warning("Host or IP string is invalid."); return; } INetworkChannel networkChannel = m_NetworkManager.GetNetworkChannel(name); if (networkChannel == null) { Log.Warning("Can not find network channel named '{0}'.", name); return; } IPAddress ipAddress = null; if (IPAddress.TryParse(hostOrIPString, out ipAddress)) { networkChannel.Connect(ipAddress, port, userData); } else { networkChannel.Connect(hostOrIPString, port, userData); } }
private void Test() { if (false) { GameEntry.Network.EventComponent = GameEntry.Event; INetworkChannelHelper channelHelper01 = new NetworkChannelHelper(); INetworkChannel channel01 = GameEntry.Network.CreateNetworkChannel("Battle", channelHelper01); channel01.HeartBeatInterval = 100f; channel01.Connect(System.Net.IPAddress.Parse("10.246.52.157"), 9099); //channel01.Connect(System.Net.IPAddress.Parse("115.159.68.24"), 9099); //Debug.Log("*****************************************"); //CSLogin msg = new CSLogin(); //for (int i = 0; i < 0; i++) //{ // msg.PlayerId = "2"; // msg.HPValue = "2"; // msg.PacketType = 7; // channel01.Send(msg, i.ToString()); //} } if (false) { GameEntry.UI.OpenUIForm(UIFormId.LoginForm, null); } if (true) { GameEntry.Resource.SetBundleBaseURL("http://123.207.181.232/dev/"); CoroutineHelper.Instance.StartCoroutine(PreDownloadInitBundle()); } }
// Use this for initialization void Start() { INetworkChannelHelper channelHelper01 = new NetworkChannelHelper(); INetworkChannel channel01 = GameEntry.Network.CreateNetworkChannel("", channelHelper01); channel01.Connect(System.Net.IPAddress.Parse("137.80.80.1"), 8888); }
public void Connect(object userData) { if (string.IsNullOrEmpty(m_HostOrIPString)) { Log.Warning("Host or IP string is invalid."); return; } IPAddress ipAddress = null; if (IPAddress.TryParse(m_HostOrIPString, out ipAddress)) { m_NetworkChannel.Connect(ipAddress, m_Port, userData); } else { m_NetworkChannel.Connect(m_HostOrIPString, m_Port, userData); } }
// Use this for initialization void Start() { NetworkChannelHelper helper = new NetworkChannelHelper(); INetworkChannel channel = StarForce.GameEntry.Network.CreateNetworkChannel("socket0", helper); //helper.Initialize(channel); IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; //IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000); StarForce.GameEntry.Event.Subscribe(UnityGameFramework.Runtime.NetworkConnectedEventArgs.EventId, OnNetworkConnected); channel.Connect(ipAddress, 11000); }
private void OnOpenUIFormSuccess(object sender, GameEventArgs e) { OpenUIFormSuccessEventArgs ne = (OpenUIFormSuccessEventArgs)e; if (ne.UserData != this) { return; } PreloadResources(); INetworkChannel channel = GameEntry.Network.CreateNetworkChannel("game", ServiceType.Tcp, new ETGameChannelHelper()); channel.Connect(IPAddress.Parse("172.16.4.112"), 7000); }
void TestConnect() { Debug.Log("-----------------Begin Connect--------------------:"); //NetworkChannelHelper netHelper = new NetworkChannelHelper(); ET_NetworkChannelHelper netHelper = new ET_NetworkChannelHelper(); //GameEntry.Network.NetworkChannelHelper = netHelper; IPAddress ip = null; if (IPAddress.TryParse("127.0.0.1", out ip)) { INetworkChannel nc = GameEntry.Network.CreateNetworkChannel("TC", netHelper); nc.HeartBeatInterval = 0f; nc.Connect(ip, 10002); } }
public void Connect(object userData) { if (string.IsNullOrEmpty(m_IPString)) { Log.Warning("IP string is invalid."); return; } IPAddress ipAddress = null; if (!IPAddress.TryParse(m_IPString, out ipAddress)) { Log.Warning("IP string '{0}' is invalid.", m_IPString); return; } m_NetworkChannel.Connect(ipAddress, m_Port, m_PacketHeaderLength, m_MaxPacketLength, userData); }
void OnConnectGateServer(object sender, EventArgs e) { Debug.Log("~~~~~~~~~~~~"); R2C_Login loginResult = sender as R2C_Login; if (loginResult == null) { return; } NetworkComponent network = GameEntry.Network; INetworkChannelHelper helper = new ET_NetworkChannelHelper(); INetworkChannel nc = network.CreateNetworkChannel("CG_TC", helper); nc.HeartBeatInterval = 0f; IPEndPoint ipPoint = NetworkHelper.ToIPEndPoint(loginResult.Address); nc.Connect(ipPoint.Address, ipPoint.Port, loginResult); }