public override void Read(ModUpdaterNetworkStream s) { base.Read(s); BlacklistedUsers = s.ReadStrings(); WhitelistedUsers = s.ReadStrings(); PostDownload = s.ReadStrings(); }
/// <summary> /// Sends a packet. /// </summary> /// <param name="p">The packet to send</param> /// <param name="Stream">The stream to send it on.</param> public static void Send(Packet p, ModUpdaterNetworkStream Stream) { if (Stream.Disposed) { return; } while (busy) { ; } busy = true; try { PacketId id = GetPacketId(p); Stream.WriteNetworkByte((byte)id); //Write timestamp Stream.WriteLong(new UnixTime().Value); //Write packet. p.Write(Stream); lastSent = p; MinecraftModUpdater.Logger.Log(Logger.Level.Debug, string.Format("Sent packet {0}", id.ToString())); } catch (Exception e) { MinecraftModUpdater.Logger.Log(e); MinecraftModUpdater.Logger.Log(e); } busy = false; }
public override void Write(ModUpdaterNetworkStream s) { base.Write(s); s.WriteStrings(BlacklistedUsers); s.WriteStrings(WhitelistedUsers); s.WriteStrings(PostDownload); }
public override void Write(ModUpdaterNetworkStream s) { int l = LogMessages.Length; s.WriteInt(l); for (int i = 0; i < l; i++) { s.WriteString(LogMessages[i]); } }
public override void Write(ModUpdaterNetworkStream s) { s.WriteInt(Servers.Length); for (int i = 0; i < Servers.Length; i++) { s.WriteString(Servers[i]); s.WriteString(Locations[i]); s.WriteInt(Ports[i]); } }
public override void Read(ModUpdaterNetworkStream s) { int l = s.ReadInt(); LogMessages = new string[l]; for (int i = 0; i < l; i++) { LogMessages[i] = s.ReadString(); } }
/// <summary> /// Starts the networking thread and begins handling packets. /// </summary> public void Start() { online = true; Stream = new ModUpdaterNetworkStream(sck); NetworkThread.Name = "Network"; NetworkThread.IsBackground = true; NetworkThread.Start(); ConnectedThread.IsBackground = true; ConnectedThread.Name = "Connection Thread"; ConnectedThread.Start(); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteString(Author); s.WriteString(ModName); s.WriteString(File); s.WriteString(Hash); s.WriteLong(FileSize); s.WriteString(Description); s.WriteString(Identifier); s.WriteBoolean(Optional); s.WriteStrings(Requires); }
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(); }
public override void Read(ModUpdaterNetworkStream s) { int i = s.ReadInt(); Servers = new string[i]; Locations = new string[i]; Ports = new int[i]; for (int j = 0; j < i; j++) { Servers[j] = s.ReadString(); Locations[j] = s.ReadString(); Ports[j] = s.ReadInt(); } }
public override void Write(ModUpdaterNetworkStream s) { s.WriteNetworkByte((byte)Type); s.WriteString(MinecraftModUpdater.Version); switch (Type) { case SessionType.Client: s.WriteString(Username); break; case SessionType.Server: s.WriteString(Address); s.WriteString(Name); s.WriteInt(Port); break; case SessionType.Admin: s.WriteString(Username); break; } }
public override void Read(ModUpdaterNetworkStream s) { Type = (SessionType)s.ReadNetworkByte(); Version = s.ReadString(); switch (Type) { case SessionType.Client: Username = s.ReadString(); break; case SessionType.Server: Address = s.ReadString(); Name = s.ReadString(); Port = s.ReadInt(); break; case SessionType.Admin: Username = s.ReadString(); break; } }
/// <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) { int i = s.ReadInt(); int j = s.ReadInt(); int k = s.ReadInt(); int l = s.ReadInt(); SData = new string[i]; IData = new int[j]; FData = new float[k]; if (i > 0) { for (int h = 0; h < i; h++) { SData[h] = s.ReadString(); } } if (j > 0) { for (int h = 0; h < j; h++) { IData[h] = s.ReadInt(); } } if (k > 0) { for (int h = 0; h < k; h++) { FData[h] = s.ReadFloat(); } } if (l > 0) { for (int h = 0; h < k; h++) { BData[h] = s.ReadBoolean(); } } }
/// <summary> /// Reads this packet from the stream. /// </summary> /// <param name="s"></param> public abstract void Read(ModUpdaterNetworkStream s);
public override void Write(ModUpdaterNetworkStream s) { if (SData == null) s.WriteInt(0); else s.WriteInt(SData.Length); if (IData == null) s.WriteInt(0); else s.WriteInt(IData.Length); if (FData == null) s.WriteInt(0); else s.WriteInt(FData.Length); if (BData == null) s.WriteInt(0); else s.WriteInt(BData.Length); try { if (SData.Length > 0) foreach (string str in SData) { s.WriteString(str); } } catch (NullReferenceException) { } //The data is null. What CAN we do? try { if (IData.Length > 0) foreach (int i in IData) { s.WriteInt(i); } } catch (NullReferenceException) { } try { if (FData.Length > 0) foreach (float f in FData) { s.WriteFloat(f); } } catch (NullReferenceException) { } try { if (BData.Length > 0) foreach (bool b in BData) { s.WriteBoolean(b); } } catch (NullReferenceException) { } }
public override void Write(ModUpdaterNetworkStream s) { s.WriteNetworkByte((byte)Type); s.WriteString(ShowOn); s.WriteBytes(Image); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteNetworkByte((byte)Type); s.WriteString(MinecraftModUpdater.Version); switch(Type) { case SessionType.Client: s.WriteString(Username); break; case SessionType.Server: s.WriteString(Address); s.WriteString(Name); s.WriteInt(Port); break; case SessionType.Admin: s.WriteString(Username); break; } }
public override void Read(ModUpdaterNetworkStream s) { Type = (ImageType)((byte)s.ReadNetworkByte()); //Stupid ReadNetworkByte(). It's in NetworkStream and thus pretty much out of my control. ShowOn = s.ReadString(); Image = s.ReadBytes(); }
public override void Read(ModUpdaterNetworkStream s) { }
public override void Write(ModUpdaterNetworkStream s) { }
public override void Read(ModUpdaterNetworkStream s) { Encrypt = s.ReadBoolean(); EncryptionKey = s.ReadBytes(); EncryptionIV = s.ReadBytes(); }
public override void Write(ModUpdaterNetworkStream s) { if (SData == null) { s.WriteInt(0); } else { s.WriteInt(SData.Length); } if (IData == null) { s.WriteInt(0); } else { s.WriteInt(IData.Length); } if (FData == null) { s.WriteInt(0); } else { s.WriteInt(FData.Length); } if (BData == null) { s.WriteInt(0); } else { s.WriteInt(BData.Length); } try { if (SData.Length > 0) { foreach (string str in SData) { s.WriteString(str); } } } catch (NullReferenceException) { } //The data is null. What CAN we do? try { if (IData.Length > 0) { foreach (int i in IData) { s.WriteInt(i); } } } catch (NullReferenceException) { } try { if (FData.Length > 0) { foreach (float f in FData) { s.WriteFloat(f); } } } catch (NullReferenceException) { } try { if (BData.Length > 0) { foreach (bool b in BData) { s.WriteBoolean(b); } } } catch (NullReferenceException) { } }
public override void Read(ModUpdaterNetworkStream s) { Type = (RequestType)s.ReadNetworkByte(); Identifier = s.ReadString(); }
public override void Read(ModUpdaterNetworkStream s) { Identifier = s.ReadString(); ChunkSize = s.ReadInt(); PostDownloadCLI = s.ReadStrings(); }
/// <summary> /// Writes this packet to the stream. /// </summary> /// <param name="s"></param> public abstract void Write(ModUpdaterNetworkStream s);
public override void Write(ModUpdaterNetworkStream s) { s.WriteStrings(Mods); }
public override void Read(ModUpdaterNetworkStream s) { Mods = s.ReadStrings(); }
public override void Read(ModUpdaterNetworkStream s) { int i = s.ReadInt(); int j = s.ReadInt(); int k = s.ReadInt(); int l = s.ReadInt(); SData = new string[i]; IData = new int[j]; FData = new float[k]; if (i > 0) for (int h = 0; h < i; h++) { SData[h] = s.ReadString(); } if (j > 0) for (int h = 0; h < j; h++) { IData[h] = s.ReadInt(); } if (k > 0) for (int h = 0; h < k; h++) { FData[h] = s.ReadFloat(); } if (l > 0) for (int h = 0; h < k; h++) { BData[h] = s.ReadBoolean(); } }
public override void Read(ModUpdaterNetworkStream s) { Identifier = s.ReadString(); }
public static void ResendLast(ModUpdaterNetworkStream Stream) { Send(lastSent, Stream); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteString(Identifier); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteString(Identifier); s.WriteInt(ChunkSize); s.WriteStrings(PostDownloadCLI); }
/// <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; }
/// <summary> /// Sends a packet. /// </summary> /// <param name="p">The packet to send</param> /// <param name="Stream">The stream to send it on.</param> public static void Send(Packet p, ModUpdaterNetworkStream Stream) { if (Stream.Disposed) return; while (busy) ; busy = true; try { PacketId id = GetPacketId(p); Stream.WriteNetworkByte((byte)id); //Write timestamp Stream.WriteLong(new UnixTime().Value); //Write packet. p.Write(Stream); lastSent = p; MinecraftModUpdater.Logger.Log(Logger.Level.Debug, string.Format("Sent packet {0}", id.ToString())); } catch (Exception e) { MinecraftModUpdater.Logger.Log(e); MinecraftModUpdater.Logger.Log(e); } busy = false; }
public override void Read(ModUpdaterNetworkStream s) { Identifier = s.ReadString(); Size = s.ReadLong(); Parts = s.ReadInt(); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteNetworkByte((byte)Type); s.WriteString(Identifier); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteBoolean(Encrypt); s.WriteBytes(EncryptionKey); s.WriteBytes(EncryptionIV); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteString(Identifier); s.WriteLong(Size); s.WriteInt(Parts); }
public override void Write(ModUpdaterNetworkStream s) { s.WriteInt(Index); s.WriteBytes(Part); s.ReadByte(); // We don't care about this number. }