-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainLoop.bas
54 lines (44 loc) · 2.31 KB
/
MainLoop.bas
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
51
52
53
54
#include once "MainLoop.bi"
#include once "Bot.bi"
Const TenMinutesInMilliSeconds As DWORD = 10 * 60 * 1000
Function MainLoop(ByVal lpParam As LPVOID)As DWORD
Dim pBot As IrcBot Ptr = lpParam
Dim objWsaData As WSAData = Any
If WSAStartup(MAKEWORD(2, 2), @objWsaData) <> 0 Then
Return 1
End If
Dim bOpenIrcClientResult As Boolean = OpenIrcClient( _
@pBot->Client, _
@pBot->IrcServer, _
@pBot->Port, _
@pBot->LocalAddress, _
@pBot->LocalPort, _
@pBot->ServerPassword, _
@pBot->BotNick, _
@pBot->UserString, _
@pBot->Description, _
True _
)
Do While pBot->ReconnectToServer
If bOpenIrcClientResult = False Then
SleepEx(60 * 1000, True)
Else
Do While WaitForSingleObjectEx(pBot->Client.hEvent, TenMinutesInMilliSeconds, True) = WAIT_IO_COMPLETION
Loop
End If
bOpenIrcClientResult = OpenIrcClient( _
@pBot->Client, _
@pBot->IrcServer, _
@pBot->Port, _
@pBot->LocalAddress, _
@pBot->LocalPort, _
@pBot->ServerPassword, _
@pBot->BotNick, _
@pBot->UserString, _
@pBot->Description, _
True _
)
Loop
WSACleanup()
Return 0
End Function