void OnConnected(object sender, EventArgs e) { var temp = e as UnityGameFramework.Runtime.NetworkConnectedEventArgs; if (temp.NetworkChannel.Name.Equals("TC")) { Debug.Log("-----------连接服务器成功-----------:"); INetworkChannel channel = GameEntry.Network.GetNetworkChannel("TC"); //channel.Send(new CSMessageTest()); Debug.Log("-----------开始发送登录请求-----------"); channel.Send(new C2R_Login() { Account = "mdzz", Password = "******" }); } else if (temp.NetworkChannel.Name.Equals("CG_TC")) { Debug.Log("-----------连接服务器再次成功-----------:"); INetworkChannel channel = GameEntry.Network.GetNetworkChannel("CG_TC"); R2C_Login r2c_Login = temp.UserData as R2C_Login; //channel.Send(new CSMessageTest()); channel.Send(new C2G_LoginGate() { Key = r2c_Login == null ? 0 : r2c_Login.Key }); } }
public override void Handle(object sender, Packet packet) { Debug.Log("Get Message From the Server"); R2C_Login loginResult = packet as R2C_Login; if (loginResult != null) { Debug.Log(string.Format("Message Content-> Address:{0}, Key->{1} ", loginResult.Address, loginResult.Key)); } r2c_Login = loginResult; //NetworkComponent network = MGame.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,r2c_Login); GameEntry.Event.Fire(r2c_Login, new MGameEvetArgs(Constant.EventDefine.ConnectGateServer)); }
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); }