/// <summary> /// 创建一个网络(lua侧使用) /// </summary> /// <param name="HeartbeatInterval">心跳时间</param> /// <param name="DetectAliveTime">超时检测</param> /// <param name="OnConnHeartbeat">心跳回调</param> /// <param name="OnConnLoss">断线回调</param> public CitrusNetWork CreateNetWork(float HeartbeatInterval, float DetectAliveTime, Action OnConnHeartbeat, Action OnConnLoss) { var network = new CitrusNetWork(); network.OnConnHeartbeat = OnConnHeartbeat; network.OnConnLoss = OnConnLoss; network.HeartbeatInterval = HeartbeatInterval; network.DetectAliveTime = DetectAliveTime; netWorkList.Add(network); return(network); }
/// <summary> /// 创建一个网络 /// </summary> public CitrusNetWork CreateNetWork(Dictionary <uint, Type> protos = null) { CitrusNetWork mNetwork = new CitrusNetWork(); mNetwork.OnConnHeartbeat = () => { //心跳包 mNetwork.SendMessage(new logic.proto.CS_Player_Tick { msg = "test" }, (cmd) => { NetworkManager.AddEvent(Protocal.Message, (ByteNetCommand)cmd); }); }; mNetwork.RegisterProtos(protos); netWorkList.Add(mNetwork); return(mNetwork); }