Thread: Packet Handling

Results 1 to 4 of 4
  1. #1 Packet Handling 
    Registered Member OP411's Avatar
    Join Date
    May 2014
    Posts
    293
    Thanks given
    28
    Thanks received
    31
    Rep Power
    0
    to start it off, I am using endeavor

    I would like to know how packets are handled
    specifically what's wrong here

    Code:
    Server side: sending
    
    public class SendUpdateExperience extends OutgoingPacket {
    
    	private final int id;
    	private final double exp;
    
    	public SendUpdateExperience(int id, double exp) {
    		super();
    		this.id = id;
    		this.exp = exp;
    	}
    
    	@Override
    	public void execute(Client client) {
    		StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(9);
    		out.writeHeader(client.getEncryptor(), 124);
    		out.writeShort(id);
    		out.writeInt((int) exp);
    		client.send(out.getBuffer());
    	}
    
    	@Override
    	public int getOpcode() {
    		return 124;
    	}
    }
    Code:
    Client sided
    
    case 124:
    				int skillID = inStream.readShort();
    				int gainedXP = inStream.readDWord();
    				int totalEXP = inStream.readDWord();
    				addXP(skillID, gainedXP);
    				totalXP = totalEXP;
    				opCode = -1;
    				return true;

    This code was already inside the server but it gives me the error packets not handled
    Where does - StreamBuffer.newOutBuffer(9); - the 9 come from?
    Is is even right? i read this - DataOutputStream (Java Platform SE 7 )
    to understand the sizes a bit better

    I am also pretty sure that the int totalEXP isn't being sent server side

    I have no idea what any of this means nor can i find information on how it works

    redirects or an explanation would be grand.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    Mk I'll take a stab at this. So data types take certain amounts of bytes.

    1 short = 2 bytes
    1 int (dword called that because d is 4 letter in alphabet or...) = 4 bytes
    1 long (q word 8th leter) = 8 bytes

    For their max values you can look at this https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

    Ok so now that we have that covered. Basically you aren't sending enough data you're missing the total xp field. The client is trying to read 3 variables you're only sending 2 to it.

    case 124
    consists of 10 bytes. 1 short and 2 ints = 10 bytes.

    That looks like a custom packet its not in my client *shrugs* anyways

    The 9 in StreamBuffer.newOutBuffer(9); is the amount of bytes the buffer is going to allocate.
    You gotta keep in consideration that the writeHeader sends one byte of data for the packet id.

    Edit: Also you want the buffer to be the exact size because the client has an array of packet sizes to check against!

    soooo long story short add another
    out.writeInt((int) exp);
    and change the size to 11.

    Did that make sense at all?

    Code:
    	@Override
    	public void execute(Client client) {
    		StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(11);
    		out.writeHeader(client.getEncryptor(), 124);
    		out.writeShort(id);
    		out.writeInt((int) exp); // TODO: Change this to xp gained.
    		out.writeInt((int) exp);
    		client.send(out.getBuffer());
    	}
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Registered Member OP411's Avatar
    Join Date
    May 2014
    Posts
    293
    Thanks given
    28
    Thanks received
    31
    Rep Power
    0
    Yes that makes a lot of sense
    fixed it
    I'll just have to explore more and learn how to use it with the information given
    thank you
    Reply With Quote  
     

  5. #4  
    Registered Member
    Join Date
    Jun 2015
    Age
    25
    Posts
    34
    Thanks given
    12
    Thanks received
    17
    Rep Power
    43
    Quote Originally Posted by Shamon King View Post
    Mk I'll take a stab at this. So data types take certain amounts of bytes.

    1 short = 2 bytes
    1 int (dword called that because d is 4 letter in alphabet or...) = 4 bytes
    1 long (q word 8th leter) = 8 bytes

    For their max values you can look at this https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

    Ok so now that we have that covered. Basically you aren't sending enough data you're missing the total xp field. The client is trying to read 3 variables you're only sending 2 to it.

    case 124
    consists of 10 bytes. 1 short and 2 ints = 10 bytes.

    That looks like a custom packet its not in my client *shrugs* anyways

    The 9 in StreamBuffer.newOutBuffer(9); is the amount of bytes the buffer is going to allocate.
    You gotta keep in consideration that the writeHeader sends one byte of data for the packet id.

    Edit: Also you want the buffer to be the exact size because the client has an array of packet sizes to check against!

    soooo long story short add another
    out.writeInt((int) exp);
    and change the size to 11.

    Did that make sense at all?

    Code:
    	@Override
    	public void execute(Client client) {
    		StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(11);
    		out.writeHeader(client.getEncryptor(), 124);
    		out.writeShort(id);
    		out.writeInt((int) exp); // TODO: Change this to xp gained.
    		out.writeInt((int) exp);
    		client.send(out.getBuffer());
    	}
    I wish I could rep you and it do something. Your response was one of the most informative I have seen on this forum. (Y)
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 15
    Last Post: 06-26-2009, 05:06 AM
  2. Replies: 14
    Last Post: 05-11-2009, 01:32 AM
  3. How RS Login and Packet Handling works?
    By Andys1481 in forum Requests
    Replies: 4
    Last Post: 05-05-2009, 08:38 PM
  4. 474 Packet handling
    By rolfcopter in forum Help
    Replies: 5
    Last Post: 04-26-2009, 05:19 PM
  5. Packet Handling Dropping
    By × Zenzie × in forum Tutorials
    Replies: 18
    Last Post: 12-16-2007, 07:18 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •