accncc / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

Had to break up message - dont know why #131

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've got quite a few spots in my code where I'm sending packets containing 5 or 
more peices of data. Never had any trouble. Today however, I wrote another 
simple little packet but at the recieving end, it simply would not accept 
anything past the 3rd item.(Was getting the "Trying to read past the buffer" 
message). I'l try to illustrate:

//Sender:
//=============
om = server.createmessage
om.Write(1);
om.Write(2);
om.Write(3);
om.Write(4);
om.Write(5);

SendMessage();

//=================

//Reciever:

SomeInt1 = msg.ReadInt32(); //no problem 
SomeInt2 = msg.ReadInt32(); //no problem 
SomeInt3 = msg.ReadInt32(); //no problem 
SomeInt4 = msg.ReadInt32(); //*error* 'Reading past buffer'
SomeInt5 = msg.ReadInt32(); 

I'm using "ReliableOrdered", and this scenario is NOT unique in my(fairly 
large) program. Any insight at all as to what is happening? 
Thanks!

Original issue reported on code.google.com by menel...@hotmail.com on 3 Sep 2012 at 9:12

GoogleCodeExporter commented 9 years ago
Forgot to mention, I got around the issue by creating an entirely new message 
for the last couple of elements.

Original comment by menel...@hotmail.com on 3 Sep 2012 at 9:14

GoogleCodeExporter commented 9 years ago
The code in your example works fine; check out the unit tests which does 10+ 
writes and reads to the same message without problems.

Original comment by lidg...@gmail.com on 4 Sep 2012 at 6:46