Via een winsock verbinding is het mogelijk om op de server alle ip adressen te zien die verbonden zijn. Maar wanneer nu iemand de verbinding verbreekt met de server wil ik dat die uit de lijst wordt verwijderd. Ik dacht dan wanneer het form wordt ge-unload dat dan een string wordt overgestuurd om zo aan te geven dat de verbinding wordt verbroken.
In de client heb ik het volgende gedaan.
Op de server doe ik dan het volgende
Maar helaas wordt ie dan niet uit de listbox verwijderd. Kan iemand me svp helpen zodat ie wel uit de lijst wordt verwijderd?
In de client heb ik het volgende gedaan.
Visual Basic:
1
2
3
| Private Sub Form_Unload(Cancel As Integer) wsMain.SendData "q" & Chr(1) & wsMain.LocalIP End Sub |
Op de server doe ik dan het volgende
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| Private Sub wsArray_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim Data As String, CtrlChar As String, X As Integer wsArray(Index).GetData Data CtrlChar = Left(Data, 1) Data = Mid(Data, 3) Select Case LCase(CtrlChar) Case "q" X = RetrieveUser(Data) lstConnectedIp.RemoveItem X .... end select end sub Private Function RetrieveUser(IpAddress As String) As Integer Dim X As Integer 'Check to see if nothing was selected If IpAddress = "" Then 'OK, nothing selected, let's see how full ' the list is! If lstConnectedIp.ListCount = 0 Then 'Nothing in the list, so return -1 RetrieveUser = -1 Exit Function End If 'If there is something in the list, send it to ' the first one =) IpAddress = lstConnectedIp.List(0) End If ' Count through the users For X = 0 To 100 'Check username to see if it is the right one If Users(X) = IpAddress Then 'Ok, this is our man, so let's return his ' winsock index RetrieveUser = X Exit Function End If Next X RetrieveUser = -1 End Function |
Maar helaas wordt ie dan niet uit de listbox verwijderd. Kan iemand me svp helpen zodat ie wel uit de lijst wordt verwijderd?