Hello,
I've been working with asynchronous sending in C# lately, and just a couple of days ago when i encountered that i needed to send multiple bits of data, i started wondering if the data sent are sent in order.
So my question is, when you send data asynchronously in c-sharp, does it send the data accordingly as it's sent?
Eg. I send an array of data holding 10 bytes, and right after i send it, i send an array holding 5 bytes, would this mean that the array holding 5 bytes would reach the remote client first (seeing as 5 bytes would most likely take less time to process than 10)
Thanks for the help in advanced. Sorry if i couldn't explain well enough.
EDIT:
Here's the code (C#):
/// <summary>
/// Sends the welcome screen to the character.
/// </summary>
/// <param name="character">The character requesting the welcome screen.</param>
public void SendWelcomeScreen(Character character)
{
SendWindowPane(character, 549);
SendInterface(character, 1, 549, 2, 378);
SendInterface(character, 1, 549, 3, 15);
SendString(character, "Welcome to " + GameEngine.World.Name + ".", 378, 115);
// TODO: last ip
SendString(character, "You are connected from: " + character.Session.Connection.IPAddress, 378, 116);
SendString(character, "0", 378, 39);
SendString(character, "0", 378, 96);
SendString(character, "0 unread messages", 378, 37);
SendString(character, GameEngine.World.Name + " staff will NEVER email you. We use the Message Centre on the website instead.", 378, 38);
SendString(character, "0 days of member credit", 378, 94);
SendString(character, "You have 0 days of member credit remaining. Please click here to extend your credit.", 378, 93);
SendString(character, "You do not have a bank pin. Please visit a bank if you would like one.", 378, 62);
SendString(character, "You have not yet set any recovery questions.", 378, 56);
SendString(character, "Message of the Week", 15, 0);
SendString(character, "Remember to keep your account secure: set a bank PIN, set recover questions and NEVER give away your password.", 15, 4);
}
/// <summary>
/// Sends a window pane to the character's client.
/// </summary>
/// <param name="character">The character to send window pane to.</param>
/// <param name="pane">The pane id.</param>
public void SendWindowPane(Character character, short pane)
{
character.Session.SendPacket(
new PacketBuilder(239)
.AppendShort(pane)
.AppendByteA(0));
}
/// <summary>
/// Sends an interface to the character's client.
/// </summary>
/// <param name="character">The character to send interface to.</param>
/// <param name="showId">The show ids.</param>
/// <param name="windowId">The window id.</param>
/// <param name="interfaceId">The interface id.</param>
/// <param name="childId">The child id.</param>
public void SendInterface(Character character, byte showId, short windowId, short interfaceId, short childId)
{
character.Session.SendPacket(
new PacketBuilder(93)
.AppendShort(childId)
.AppendByteA(showId)
.AppendShort(windowId)
.AppendShort(interfaceId));
}
/// <summary>
/// Sends a piece of text to the character's client.
/// </summary>
/// <param name="character">The character to send the text to.</param>
/// <param name="text">The string to be displayed.</param>
/// <param name="interfaceId">The interface id of which we place this text on.</param>
/// <param name="childId">The child id of which we place this text on.</param>
public void SendString(Character character, string text, short interfaceId, short childId)
{
int stringSize = text.Length + 5;
character.Session.SendPacket(
new PacketBuilder(179)
.AppendByte((byte)(stringSize / 256))
.AppendByte((byte)(stringSize % 256))
.AppendString(text)
.AppendShort(childId)
.AppendShort(interfaceId));
}