Exemplo n.º 1
0
        public void SendFileInfo(string Filename, string Checksum, long Size, bool End)
        {
            LauncherPacket Packet = new LauncherPacket(0x0004);

            Packet.WriteString(Filename);
            Packet.WriteString(Checksum);
            Packet.WriteLong(Size);
            Packet.WriteBool(End);
            Send(Packet);
        }
Exemplo n.º 2
0
        public void SendInformation()
        {
            LauncherPacket Packet = new LauncherPacket(0x0006);

            Packet.WriteString(ServerConfiguration.SiteLink);
            Packet.WriteString(ServerConfiguration.RegisterLink);
            Packet.WriteString(ServerConfiguration.NewsLink);
            Packet.WriteString(ServerConfiguration.UpdateLink);
            Packet.WriteString(ServerConfiguration.GameExecutable);
            Packet.WriteString(ServerConfiguration.GameParameters);
            Packet.WriteString(ServerConfiguration.GameWorkingDirectory);
            Send(Packet);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        protected void HandleClientVersion(LauncherPacket Packet)
        {
            int Major = Packet.ReadInt();
            int Minor = Packet.ReadInt();

            if (Major != int.Parse(ServerConfiguration.MajorVersion) || Minor != int.Parse(ServerConfiguration.MinorVersion))
            {
                Client.SendInvalidVersion();
                Client.Disconnect();
            }
            else
            {
                ClientVersion = true;
                Client.SendInformation();
                HandleSendList();
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        //Read packet
        private void PacketReceived(LauncherPacket Packet)
        {
            switch (Packet.ID)
            {
            case 0x0001:
                HandleClientVersion(Packet);
                break;

            case 0x0003:
                HandleSendList();
                break;

            case 0x0005:
                HandleInformationRequest();
                break;

            default:
                LogFactory.GetLog(this).LogInfo("Invalid packet({1}) received from client <{0}>!", EndPoint, Packet.ID);
                Disconnect();
                break;
            }
        }
Exemplo n.º 7
0
        public void SendEndList()
        {
            LauncherPacket Packet = new LauncherPacket(0x0007);

            Send(Packet);
        }
Exemplo n.º 8
0
        public void SendInvalidVersion()
        {
            LauncherPacket Packet = new LauncherPacket(0x0002);

            Send(Packet);
        }
Exemplo n.º 9
0
        public void SendVersionRequest()
        {
            LauncherPacket Packet = new LauncherPacket(0x0001);

            Send(Packet);
        }