public override void Read(ModUpdaterNetworkStream s) { Author = s.ReadString(); ModName = s.ReadString(); File = s.ReadString(); Hash = s.ReadString(); FileSize = s.ReadLong(); Description = s.ReadString(); Identifier = s.ReadString(); Optional = s.ReadBoolean(); Requires = s.ReadStrings(); }
/// <summary> /// Reads the next packet in the stream. /// </summary> /// <param name="Stream">The stream to read from</param> /// <returns>A fully read packet.</returns> public static Packet ReadPacket(ModUpdaterNetworkStream Stream) { Type Packet = null; Packet p = null; if (Stream.Disposed) { return(null); } try { PacketId id = PacketId.Disconnect; try { id = (PacketId)Stream.ReadNetworkByte(); } catch (MalformedPacketException) { return(null); } if (!Map.ContainsValue(id)) { Stream.Flush(); return(null); } MinecraftModUpdater.Logger.Log(Logger.Level.Debug, string.Format("Read packet {0}", id.ToString())); foreach (var v in Map) { if (v.Value == id) { Packet = v.Key; } } p = (Packet)Packet.GetConstructor(new Type[] { }).Invoke(null); p.Timestamp = new UnixTime(Stream.ReadLong()).ToDateTime(); p.Read(Stream); lastRecived = p; } catch (MalformedPacketException e) { throw new MalformedPacketException(e.Message, e); } catch (Exception e) { MCModUpdaterExceptionHandler.HandleException(p, e); } return(p); }
public override void Read(ModUpdaterNetworkStream s) { Identifier = s.ReadString(); Size = s.ReadLong(); Parts = s.ReadInt(); }
/// <summary> /// Reads the next packet in the stream. /// </summary> /// <param name="Stream">The stream to read from</param> /// <returns>A fully read packet.</returns> public static Packet ReadPacket(ModUpdaterNetworkStream Stream) { Type Packet = null; Packet p = null; if (Stream.Disposed) return null; try { PacketId id = PacketId.Disconnect; try { id = (PacketId)Stream.ReadNetworkByte(); } catch (MalformedPacketException) { return null; } if (!Map.ContainsValue(id)) { Stream.Flush(); return null; } MinecraftModUpdater.Logger.Log(Logger.Level.Debug, string.Format("Read packet {0}", id.ToString())); foreach (var v in Map) { if (v.Value == id) { Packet = v.Key; } } p = (Packet)Packet.GetConstructor(new Type[] { }).Invoke(null); p.Timestamp = new UnixTime(Stream.ReadLong()).ToDateTime(); p.Read(Stream); lastRecived = p; } catch (MalformedPacketException e) { throw new MalformedPacketException(e.Message, e); } catch (Exception e) { MCModUpdaterExceptionHandler.HandleException(p, e); } return p; }