Esempio n. 1
0
        //Read packet
        private void PacketReceived(LauncherPacket Packet)
        {
            switch (Packet.ID)
            {
            case 0x0001:
                HandleClientVersion();
                break;

            case 0x0002:
                HandleInvalidVersion();
                break;

            case 0x0004:
                HandleFileList(Packet);
                break;

            case 0x0006:
                HandleServerInformation(Packet);
                break;

            case 0x0007:
                HandleEndList();
                break;
            }
        }
Esempio n. 2
0
        public static void SendClientVersion()
        {
            LauncherPacket Packet = new LauncherPacket(0x0001);

            Packet.WriteInt(App.MajorVersion);
            Packet.WriteInt(App.MinorVersion);
            Instance.Send(Packet);
        }
Esempio n. 3
0
 protected void HandleServerInformation(LauncherPacket Packet)
 {
     SiteLink             = Packet.ReadString();
     RegisterLink         = Packet.ReadString();
     NewsLink             = Packet.ReadString();
     UpdateLink           = Packet.ReadString();
     GameExecutable       = Packet.ReadString();
     GameParameters       = Packet.ReadString();
     GameWorkingDirectory = Packet.ReadString();
 }
Esempio n. 4
0
        protected void HandleFileList(LauncherPacket Packet)
        {
            string File = Packet.ReadString();
            string Hash = Packet.ReadString();
            long   Size = Packet.ReadLong();

            List.Add(new Client.File {
                Filename = File, Hash = Hash, Size = Size
            });
            App.SyncCallback(() => FileInfoReceived(null, EventArgs.Empty));
            LauncherClient.SendListRequest();
        }
Esempio n. 5
0
        private void Send(LauncherPacket Packet)
        {
            lock (syncLock)
            {
                byte[] IDBuffer = BitConverter.GetBytes(Packet.ID);
                ClientStream.Write(IDBuffer, 0, IDBuffer.Length);

                byte[] SizeBuffer = BitConverter.GetBytes(Packet.Buffer.Length);
                ClientStream.Write(SizeBuffer, 0, SizeBuffer.Length);

                byte[] Buffer = Packet.Buffer;
                ClientStream.Write(Buffer, 0, Buffer.Length);
            }
        }
Esempio n. 6
0
        //Read callback
        private void ClientCallback()
        {
            try
            {
                while (true)
                {
                    byte[] IDBuffer = new byte[sizeof(int)];
                    if (ClientStream.Read(IDBuffer, 0, IDBuffer.Length) == 0)
                    {
                        break;
                    }

                    byte[] SizeBuffer = new byte[sizeof(int)];
                    if (ClientStream.Read(SizeBuffer, 0, SizeBuffer.Length) == 0)
                    {
                        break;
                    }

                    byte[] Buffer = new byte[BitConverter.ToInt32(SizeBuffer, 0)];
                    if (Buffer.Length > 0)
                    {
                        if (ClientStream.Read(Buffer, 0, Buffer.Length) == 0)
                        {
                            break;
                        }
                    }

                    LauncherPacket Packet = new LauncherPacket(BitConverter.ToInt32(IDBuffer, 0), Buffer);
                    PacketReceived(Packet);

                    Thread.Sleep(10);
                }
            }
            catch (SocketException) { }
            catch (IOException) { }
            catch (ThreadInterruptedException) { }
            catch (Exception e)
            {
                LogFactory.GetLog(this).LogFatal(e);
            }
            Disconnect();
        }
Esempio n. 7
0
        public static void SendListRequest()
        {
            LauncherPacket Packet = new LauncherPacket(0x0003);

            Instance.Send(Packet);
        }