コード例 #1
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     base.Read(s);
     BlacklistedUsers = s.ReadStrings();
     WhitelistedUsers = s.ReadStrings();
     PostDownload     = s.ReadStrings();
 }
コード例 #2
0
 /// <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;
 }
コード例 #3
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     base.Read(s);
     BlacklistedUsers = s.ReadStrings();
     WhitelistedUsers = s.ReadStrings();
     PostDownload = s.ReadStrings();
 }
コード例 #4
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     base.Write(s);
     s.WriteStrings(BlacklistedUsers);
     s.WriteStrings(WhitelistedUsers);
     s.WriteStrings(PostDownload);
 }
コード例 #5
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     base.Write(s);
     s.WriteStrings(BlacklistedUsers);
     s.WriteStrings(WhitelistedUsers);
     s.WriteStrings(PostDownload);
 }
コード例 #6
0
        public override void Write(ModUpdaterNetworkStream s)
        {
            int l = LogMessages.Length;

            s.WriteInt(l);
            for (int i = 0; i < l; i++)
            {
                s.WriteString(LogMessages[i]);
            }
        }
コード例 #7
0
 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]);
     }
 }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
 /// <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();
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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();
 }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
        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;
            }
        }
コード例 #14
0
        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;
            }
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        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();
                }
            }
        }
コード例 #17
0
 /// <summary>
 /// Reads this packet from the stream.
 /// </summary>
 /// <param name="s"></param>
 public abstract void Read(ModUpdaterNetworkStream s);
コード例 #18
0
 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);
 }
コード例 #19
0
 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) { }
 }
コード例 #20
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     int l = LogMessages.Length;
     s.WriteInt(l);
     for (int i = 0; i < l; i++)
     {
         s.WriteString(LogMessages[i]);
     }
 }
コード例 #21
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteNetworkByte((byte)Type);
     s.WriteString(ShowOn);
     s.WriteBytes(Image);
 }
コード例 #22
0
 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;
     }
 }
コード例 #23
0
 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();
 }
コード例 #24
0
 public override void Read(ModUpdaterNetworkStream s)
 {
 }
コード例 #25
0
 public override void Write(ModUpdaterNetworkStream s)
 {
 }
コード例 #26
0
 /// <summary>
 /// Reads this packet from the stream.
 /// </summary>
 /// <param name="s"></param>
 public abstract void Read(ModUpdaterNetworkStream s);
コード例 #27
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Encrypt       = s.ReadBoolean();
     EncryptionKey = s.ReadBytes();
     EncryptionIV  = s.ReadBytes();
 }
コード例 #28
0
 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) { }
 }
コード例 #29
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Type = (RequestType)s.ReadNetworkByte();
     Identifier = s.ReadString();
 }
コード例 #30
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteNetworkByte((byte)Type);
     s.WriteString(ShowOn);
     s.WriteBytes(Image);
 }
コード例 #31
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier      = s.ReadString();
     ChunkSize       = s.ReadInt();
     PostDownloadCLI = s.ReadStrings();
 }
コード例 #32
0
 /// <summary>
 /// Writes this packet to the stream.
 /// </summary>
 /// <param name="s"></param>
 public abstract void Write(ModUpdaterNetworkStream s);
コード例 #33
0
 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();
 }
コード例 #34
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteStrings(Mods);
 }
コード例 #35
0
 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();
     }
 }
コード例 #36
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Mods = s.ReadStrings();
 }
コード例 #37
0
 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();
         }
 }
コード例 #38
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier = s.ReadString();
 }
コード例 #39
0
 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();
 }
コード例 #40
0
 public static void ResendLast(ModUpdaterNetworkStream Stream)
 {
     Send(lastSent, Stream);
 }
コード例 #41
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier = s.ReadString();
     ChunkSize = s.ReadInt();
     PostDownloadCLI = s.ReadStrings();
 }
コード例 #42
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
 }
コード例 #43
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteStrings(Mods);
 }
コード例 #44
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
     s.WriteInt(ChunkSize);
     s.WriteStrings(PostDownloadCLI);
 }
コード例 #45
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
     s.WriteInt(ChunkSize);
     s.WriteStrings(PostDownloadCLI);
 }
コード例 #46
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier = s.ReadString();
 }
コード例 #47
0
 /// <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;
 }
コード例 #48
0
 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]);
     }
 }
コード例 #49
0
 /// <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;
 }
コード例 #50
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier = s.ReadString();
     Size = s.ReadLong();
     Parts = s.ReadInt();
 }
コード例 #51
0
 /// <summary>
 /// Writes this packet to the stream.
 /// </summary>
 /// <param name="s"></param>
 public abstract void Write(ModUpdaterNetworkStream s);
コード例 #52
0
 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;
     }
 }
コード例 #53
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteNetworkByte((byte)Type);
     s.WriteString(Identifier);
 }
コード例 #54
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteBoolean(Encrypt);
     s.WriteBytes(EncryptionKey);
     s.WriteBytes(EncryptionIV);
 }
コード例 #55
0
 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();
     }
 }
コード例 #56
0
 public override void Read(ModUpdaterNetworkStream s)
 {
     Identifier = s.ReadString();
     Size       = s.ReadLong();
     Parts      = s.ReadInt();
 }
コード例 #57
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
 }
コード例 #58
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
     s.WriteLong(Size);
     s.WriteInt(Parts);
 }
コード例 #59
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteString(Identifier);
     s.WriteLong(Size);
     s.WriteInt(Parts);
 }
コード例 #60
0
 public override void Write(ModUpdaterNetworkStream s)
 {
     s.WriteInt(Index);
     s.WriteBytes(Part);
     s.ReadByte(); // We don't care about this number.
 }