Author Topic: C# Bistream  (Read 10260 times)

aarzkhan

  • Not-a-newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
C# Bistream
« on: March 20, 2012, 12:30:45 PM »
So I'm probably doing something stupid again but whenever i try to use bitstream.Read it doesnt work I'm using:
RakString message = new RakString();
BitStream bitStream = new BitStream(packet.data, packet.length, false);
bitStream.IgnoreBytes(sizeof(DefaultMessageIDTypes));
bitStream.Read(message);

to read the packet data but message seems to be empty after this here's what i'm sending:
clientStream.Write((byte)GameMessages.ID_GAME_MESSAGE_1);
clientStream.Write("Hello Server");
peerInterface.Send(clientStream, HIGH_PRIORITY, RELIABLE_ORDERED, (char)0, sendAddress, false);

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: C# Bistream
« Reply #1 on: March 20, 2012, 02:45:52 PM »
If you try to read the first byte, does that work?

aarzkhan

  • Not-a-newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: C# Bistream
« Reply #2 on: March 20, 2012, 04:36:43 PM »
I can read the packet.data[0] and it comes out as correct

NeptuneX

  • Guest
Re: C# Bistream
« Reply #3 on: April 26, 2012, 12:34:55 AM »
i think sizeof(DefaultMessageIDTypes)=4
maybe just bitStream.IgnoreBytes(1) is ok.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: C# Bistream
« Reply #4 on: April 26, 2012, 09:12:53 AM »
OK that is it. Do not use bitStream.IgnoreBytes(sizeof(DefaultMessageIDTypes)); but use IgnoreBytes(1) or IgnoreBytes(sizeof(RakNet::MessageID));

I didn't see that earlier.