Jump to content

Encoding Used by BankStream


Go to solution Solved by Josh,

Recommended Posts

Posted

Hi again. Messing around with the built in networking (ENet), I wrote a C# app for testing with an ENet Library wrapper. I'm able to connect and send messages but I'm not quite sure how to parse a bank stream on my server's end. Any ideas from C#?

For example if I send a string "this is a test" using Client:Send in Leadwerks, my server will see "? This is a test" the question mark being a wrongly parsed symbol which I assume is the message ID from Leadwerks. 

var dataString = Encoding.ASCII.GetString(Event.Packet.Data);

 

Posted

By the way, your suggestion was correct, I was able to take the first 4 bytes and convert them to the message ID.

I will still need a way to handle the other types afterwards though like WriteFloat and WriteInt.

Posted
int i = 0;

byte[] bytes = new byte[4];

foreach (var element in Event.Packet.Data)
{
  if (i < 4)
  {
    bytes[i] = element;
  }

  i++;
}

int eventId = BitConverter.ToInt32(bytes, 0);

Really quick example that I'm going to turn into a BankStream class for C# but I'm able to get the Event ID and next int. Floats seem to use a different size and for strings, I'm not sure what the separation you use is.

Posted

Any idea on why my floats aren't reading correctly? Writing float 1 for example produces:
1.1754944E-38

Writing float 9 produces:

1.469368E-39

 

Here's my code: 

float f1 = BitConverter.ToSingle(bytes2, 0);

 

Seems like the bytes are in a different order possibly? 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...