VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim i As Long
Winsock1.GetData strIncoming
If strIncoming = ".badlogin" Then
MsgBox "The screen name or password you entered is not valid. ", vbOKOnly + vbCritical
If Winsock1.State <> sckClosed Then
Winsock1.Close
End If
ElseIf strIncoming = ".goodlogin" Then
Call good_login
ElseIf strIncoming = "nogood" Then
Call nogood1
ElseIf Word(strIncoming, 1) = ".showonline" And Word(strIncoming, 2) <> "0" Then
Call Show_Online_buddies(strIncoming)
ElseIf Word(strIncoming, 1) = ".statusUpdate" And Word(strIncoming, 2) <> "0" Then
[COLOR=Red]Call status_update(Word(strIncoming, 2), Word(strIncoming, 3))[/COLOR]
ElseIf Word(strIncoming, 1) = ".msg" Then
Call get_message(Word(strIncoming, 2), strIncoming)
ElseIf Word(strIncoming, 1) = ".define" Then
Call get_definition(Word(strIncoming, 2), Word(strIncoming, 3), strIncoming)
ElseIf Word(strIncoming, 1) = ".spell" Then
Call get_spelling(Word(strIncoming, 2), strIncoming)
End If
End Sub
VB Code:
Private Function update_status(status As Integer, user As String, Index As Integer)
Dim sConnString As String
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=imdb.mdb"
Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim conn As New ADODB.Connection
conn.Open sConnString
If ServiceSocket(Index).State = sckConnected Then
rs2.Open "UPDATE online SET ostatus = " + _
CStr(status) + " WHERE username = '" + _
CStr(user) + "' AND oindex = " + _
CStr(Index), conn
End If
'Gets the ppl that have user as buddies that are currently online
rs.Open "SELECT buddy, oindex FROM buddies, online WHERE buddies.buddy = '" + _
CStr(user) + "' AND buddies.user = online.username", conn
While rs.EOF = False
'Im not too sure about this part of the code...it seems it would work, not sure
'if its the best code though
For i = 1 To ServiceSocket.UBound
testing = ServiceSocket(i).Index
If ServiceSocket(i).Index = rs.Fields("oindex") Then
If ServiceSocket(i).State = sckConnected Then
ServiceSocket(i).SendData ".statusUpdate 1" & " " & user & " " & status 'send status of user to its buddies if their online
End If
End If
Next i
rs.MoveNext
Wend
If ServiceSocket(Index).State = sckConnected Then
ServiceSocket(Index).SendData ".statusUpdate 0"
End If
Set rs = Nothing
Set rs2 = Nothing
Set conn = Nothing
End Function