public void PacketArrived(InPacket inPacket) { try { foreach (IPacketListener listener in listeners) { if (listener.Accept(inPacket)) { listener.PacketArrived(inPacket); return; } } } catch (Exception e) { client.LogManager.Log(ToString() + ":" + e.Message + "\n\r" + e.StackTrace); ErrorPacket errorPacket = new ErrorPacket(ErrorPacketType.RUNTIME_ERROR, client,e); errorPacket.ErrorMessage = client.GenerateCrashReport(e, inPacket); errorPacket.Family = ProtocolFamily.Basic; errorPacket.ConnectionId = TS.QQ.Net.QQPort.Main.Name; client.PacketManager.AddIncomingPacket(errorPacket, errorPacket.ConnectionId); } }
/// <summary>触发超时事件 /// </summary> /// <param name="packet">The packet.</param> private void FireOperationTimeOutEvent(OutPacket packet, string portName) { ErrorPacket error = new ErrorPacket(ErrorPacketType.ERROR_TIMEOUT, client); error.TimeOutPacket = packet; error.Header = packet.Header; error.Family = packet.GetFamily(); error.ConnectionId = portName; client.PacketManager.AddIncomingPacket(error, portName); }
/// <summary> /// 创建一个错误包 /// </summary> /// <param name="errorCode">The error code.</param> /// <returns></returns> public ErrorPacket CreateErrorPacket(ErrorPacketType errorCode, string portName, Exception e) { ErrorPacket errorPacket = new ErrorPacket(errorCode, client, e); errorPacket.Family = SupportedFamily; errorPacket.ConnectionId = portName; return errorPacket; }