|
-
Aug 30th, 2006, 02:03 AM
#1
Thread Starter
Member
[RESOLVED] Help with VB6 Network coding! Doesn't go in correct order!
Ok I've been using this coding for awhile, the deeper I got into it I realized that it doesn't do everything in order.
VB Code:
Private Sub WStcpClient_DataArrival(ByVal bytesTotal As Long)
Static sBuffer As String
Dim Data As String, DataArray() As String, ComArray() As String
Dim i As Integer, j As Integer, ComI As Integer
'Get the data from WinSock, Seperate Packets and add each packet (A Command) to the Command Array
WStcpClient.GetData Data
Data = sBuffer & Data
ComArray = Split(Data, packetDelimiter)
'Save the stuff to carry over to the next event
sBuffer = ComArray(UBound(ComArray))
'Loop Through All Commands (Packets) Recieved
'The last entry is incomplete or "" so ignore it
For ComI = 0 To UBound(ComArray) - 1
'Error Handle, If No Data then go to next
If ComArray(ComI) <> "" Then
'Stop Loop Hogging resources
DoEvents
MsgBox ComArray(ComI) 'VIEW INPUT DATA FOR DEBUG
'Now Split the current command (Packet) into the Data Array (Array Of Variables unique to the command code
' (The command code is in place Zero of the array and is a two letter code telling the client what command to
' process, the remaining places are variables needed to do the command )
DataArray = Split(ComArray(ComI), packetDelimiter)
'####Data in Data Array Is Proccesed here####
Call ProcessData(ComArray(), ComI)
End If
Next ComI
End Sub
Generally it will process it after wards. but lets say it recieves three things to display in a textbox all at once, but sent out are these:
"1"
"2"
"3"
when you put the debugger on you see it in order, but when it finishes processing in the textbox/etc you will see it in the order backwards more or less, generally what would be displayed is
"3"
"2"
"1"
This only happens when the coding is sent quicker. Can anyone tell why? I found this out when the NPC was attacking before entering the room, generally when I put the debugger on, you'd see the enter room message being first, then the attacks, but since it was all together, it ended up attacking first then you'd see him enter the room.
What it seems like more or less it processes the last thing it gets first.. Not sure what to do.
Last edited by Valleriani; Jan 9th, 2007 at 01:28 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|