private IEnumerator BeginSendPacket <T>(int network_message, T packet, bool timeout_message, byte[] msg_index_bytes) where T : global::ProtoBuf.IExtensible { // 每一条消息的的下标 string msg_id = BitConverter.ToString(msg_index_bytes); lock (_msg_index_map) { _msg_index_map.Add(msg_id, packet); } NetLog.Log("发送消息 : {0} 消息下标 :{1}", network_message, msg_id); DoBeginSendPacket <T>(network_message, packet, msg_index_bytes); yield return(CoroutineConst.GetWaitForSeconds(NetworkConst.REQ_TIME_OUT)); // 等待超时时间之后,检测超时情况 LogManager.Error("超时:[{0}]", network_message); // 移除相关的回调信息 lock (_msg_index_map) { bool result = RemoveMsgIndex(msg_id); if (result && timeout_message)// 然后提示超时 { NetworkEventSystem.Instance.RaiseEvent(E_NetModule.req_timeout, null); } } }
public IEnumerator CheckAllEffect() { yield return(CoroutineConst.GetWaitForSeconds(1f)); // 1. 读取 特效的列表 ReadCsv(); yield return(CoroutineConst.GetWaitForSeconds(0.5f)); // 2. 依次解析特效的dc和三角面 foreach (var report in _reportMap) { yield return(StartCoroutine(AnalyzeSingleFx(report.Value))); } // 3. 输出文本 WriteCsv(); }
public IEnumerator _do_loop_by_condition(float interval, Func <bool> condition, Action call_back, float delay_time) { if (delay_time > 0f) { yield return(CoroutineConst.GetWaitForSeconds(delay_time)); } // ReSharper disable once NotAccessedVariable int tmp_loop_count = 0; // ReSharper disable once LoopVariableIsNeverChangedInsideLoop while (condition()) { tmp_loop_count++; call_back(); yield return(CoroutineConst.GetWaitForSeconds(interval)); } }
/// <summary> /// 每帧进行循环 /// </summary> public IEnumerator _do_loop_by_every_frame(int loop_count, Action call_back, float delay_time) { // 循环次数,回调,开始时间 if (delay_time > 0f) { yield return(CoroutineConst.GetWaitForSeconds(delay_time)); } if (loop_count <= 0) { loop_count = int.MaxValue; } int tmp_loop_count = 0; while (tmp_loop_count < loop_count) { tmp_loop_count++; call_back(); yield return(CoroutineConst._waitForEndOfFrame); } }
/// <summary> /// 间隔时间进行多次动作 /// </summary> public IEnumerator _do_loop_by_time(float interval, Action call_back, int loop_count = 1, float delay_time = 0f) { // 间隔时间,循环次数,回调,延迟时间时间 if (delay_time > 0f) { yield return(CoroutineConst.GetWaitForSeconds(delay_time)); } if (loop_count <= 0) { loop_count = int.MaxValue; } int tmp_loop_count = 0; while (tmp_loop_count < loop_count) { tmp_loop_count++; call_back(); yield return(CoroutineConst.GetWaitForSeconds(interval)); } }
public IEnumerator BeginConnection() { try { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _socket.BeginConnect(NetworkConst.ip_address, NetworkConst.ip_port, _finish_connect, null); } catch (Exception ex) { LogManager.Error(ex.StackTrace); yield break; } yield return(CoroutineConst.GetWaitForSeconds(NetworkConst.CONNECT_TIME_OUT)); if (!_socket.Connected) { LogManager.Error("Client Connect Time Out..."); CloseConnection(); } _is_keep_alive = _socket.Connected; }
// 等待一定的时间 public IEnumerator _do_wait_to_do(float time) { yield return(CoroutineConst.GetWaitForSeconds(time)); }