-
Notifications
You must be signed in to change notification settings - Fork 0
/
pingSender.cs
61 lines (54 loc) · 1.65 KB
/
pingSender.cs
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
55
56
57
58
59
60
61
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
/*
* Class that sends PING to irc server every 15 seconds
*/
class PingSender
{
static string PING = "PING :";
private Thread pingSender;
private Thread payGiver;
// Empty constructor makes instance of Thread
public PingSender()
{
pingSender = new Thread(new ThreadStart(this.Run));
payGiver = new Thread(new ThreadStart(this.Pay));
}
// Starts the thread
public void Start()
{
pingSender.Start();
payGiver.Start();
}
// Send PING to irc server every minutes
public void Run()
{
while (true)
{
foreach(User us in Users.list)
{
us.watchTime ++;
XmlProcess.Write("xml\\users.xml","User",us.name,us.admin.ToString(),us.currency.ToString(),us.watchTime.ToString(),us.hp.ToString(),us.def.ToString(),us.atk.ToString(),us.rep.ToString());
}
IrcBot.Send(PING + IrcBot.SERVER);
Thread.Sleep (60000);
}
}
// Gives the payout at each intervals
public void Pay()
{
while (true)
{
Thread.Sleep(IrcBot.currencyInterval * 60000);
foreach(User us in Users.list)
{
us.currency += IrcBot.currencyPayout;
}
IrcBot.writeLine("Payout !! +"+IrcBot.currencyPayout+" to everyone", ConsoleColor.White);
IrcBot.Send("PRIVMSG " + IrcBot.CHANNEL + " :/me +"+IrcBot.currencyPayout+" "+IrcBot.oneCurrency+" for everyone!");
}
}
}