Private Sub Form_Activate()
Dim strIp As String
If isLoaded = False Then
strIp = SckListen(0).LocalIP
SckListen(0).LocalPort = 1001
SckListen(0).Listen
objData.addChatUser User, strIp
If isDemo = True Then
demoValidate
End If
isLoaded = True
End If
End Sub
Private Sub SckListen_ConnectionRequest(Index As Integer, ByVal requestID As Long)
If SckListen(0).State <> sckClosed Then SckListen(0).Close
If Index = 0 Then
intSckIndex = intSckIndex + 1
Load SckListen(intSckIndex)
SckListen(intSckIndex).LocalPort = 0
SckListen(intSckIndex).Accept requestID
End If
End Sub
'In another form
Private Sub cmdChat_Click()
Dim txtSelected
Dim intCount As Integer
Dim isSel As Boolean
Dim strSend As String
Dim strChatName As String
Dim strHost As String
Dim isConnect As Boolean
isSel = False
For intCount = 0 To List1.ListCount - 1
If List1.Selected(intCount) = True Then
isSel = True
End If
Next intCount
If isSel = False Then
msg = MsgBox("Please Select a user!", vbInformation)
Exit Sub
End If
Set frmChat = New frmClientChat
intFrmChatCount = FrmChatCol.count + 1
strChatName = User & " Session " & intFrmChatCount
frmChat.Tag = strChatName
FrmChatCol.Add frmChat, frmChat.Tag
For intCount = 0 To List1.ListCount - 1
If List1.Selected(intCount) = True Then
intSckIndex = intSckIndex + 1
Load frmDesktop.SckListen(intSckIndex)
strHost = objData.getChatHost(List1.List(intCount))
frmDesktop.SckListen(intSckIndex).Connect strHost, 1001
If frmDesktop.SckListen(intSckIndex).State = sckConnected Then
strSend = "REQUEST" & Chr$(182) & User & Chr$(182) & strChatName
frmDesktop.SckListen(intSckIndex).SendData strSend
End If
End If
Next intCount
frmChat.Show
Unload Me
End Sub