• Welcome to Valhalla Legends Archive.
 

[VB6 SOLVED] Data being received multiple times

Started by l2k-Shadow, February 17, 2006, 10:12 PM

Previous topic - Next topic

l2k-Shadow

Alright, well I'm making a filter gateway for battle.net clients, so that instead of client->server connection it goes client->gateway->server... and it's giving me a problem of the client receiving the data sent by my program multiple times:


My code for receiving Battle.net data:

Private Sub wsBNET_DataArrival(ByVal bytesTotal As Long)
Static Buffer As String
Dim Data As String, Length As Long
    Call wsBNET.GetData(Data, vbString, bytesTotal)
    Buffer = Buffer & Data
    While Len(Buffer) >= 4
        Length = GetWORD(Mid$(Buffer, 3, 2))
        If Length > Len(Buffer) Then Exit Sub
        Call ParseRecvData(Buffer)
        Buffer = Mid$(Buffer, Length + 1)
    Wend
End Sub

Code for ParseRecvData():

Public Sub ParseRecvData(ByVal Data As String)
    Select Case Asc(Mid$(Data, 2, 1))
        Case &HA:
            Con.Username = TrimString(Mid$(Data, 5))
        Case &H50:
            Con.ServerToken = GetDWORD(Mid$(Data, 9, 4))
            Con.MPQNumber = CInt(Mid$(Data, 32, 1))
            Con.HashValue = TrimString(Mid$(Data, 38))
    End Select
    Call frmMain.wsListen.SendData(Data)
End Sub


Any ideas? I tried using DoEvents and checking if the Data was already sent by the socket but it still happens... any input is appreciated. Thanks.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

Ringo

Ah, i had this problem a few times, i think it was because of the static string.
(I take it this only happens now and then?)
try:

Private Sub wsBNET_DataArrival(ByVal bytesTotal As Long)
Static Buffer As String
Dim Data As String, Length As Long
    Call wsBNET.GetData(Data, vbString, bytesTotal)
    Buffer = Buffer & Data
    While Len(Buffer) >= 4
        Length = GetWORD(Mid$(Buffer, 3, 2))
        If Length > Len(Buffer) Then Exit Sub
        Data = left(Buffer, lengh)
        Call ParseRecvData(Data)
        buffer = mid(buffer, 1 + lengh)
    Wend
End Sub


Hope this helps

l2k-Shadow

omg Ringo you rock. thanks much.. although I still don't understand why it happens in the first place.. I guess another gay VB thing.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.