-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (40 loc) · 1.08 KB
/
main.cpp
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
#include <unistd.h>
#include "globals.h"
#include "model/ModelDriver.h"
#include "view/ViewDriver.h"
#include "controller/ControllerDriver.h"
int main(int argc, char ** argv)
{
bool running = true;
ModelDriver md(&running);
ViewDriver vd(&md);
ControllerDriver cd(&running, &md, &vd);
if (argc != 5) {
md.setSelectedWindow(FIRSTWINDOW);
while (running) {
md.updateFirstRun();
cd.getInputFirstRun();
vd.drawFirstRun();
usleep(DELAY);
}
return 0;
}
md.setUsername(argv[1]);
md.setPassword(argv[2]);
md.setHost(argv[3]);
md.setPort(atoi(argv[4]));
while (running) {
md.update();
cd.getInput();
vd.draw();
usleep(DELAY);
}
if (strcmp(md.selectedRoom, "")) {
char response[MAX_RESPONSE];
char leaveRoom[100];
sprintf(leaveRoom, "%s leaves the room.", md.selectedRoom);
md.sendCommand("SEND-MESSAGE", leaveRoom, response);
md.sendCommand("LEAVE-ROOM", md.selectedRoom, response);
}
return 0;
}