-
Notifications
You must be signed in to change notification settings - Fork 0
/
JungleServer.java
52 lines (40 loc) · 1.28 KB
/
JungleServer.java
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
//FINI
import java.io.*;
import java.net.*;
class JungleServer {
public final static int REQ_LISTPARTY = 1;
public final static int REQ_CREATEPARTY = 2;
public final static int REQ_JOINPARTY = 3;
public final static int REQ_WAITPARTYSTARTS = 4;
public final static int REQ_WAITTURNSTARTS = 5;
public final static int REQ_PLAY = 6;
public final static int ACT_NOP = 1;
public final static int ACT_TAKETOTEM = 2;
public final static int ACT_HANDTOTEM = 3;
public final static int ACT_INCORRECT = 4;
public static void main(String []args) {
ServerSocket conn = null;
Socket comm = null;
Game game = null;
int port = 12345;
ThreadServer t = null;
try {
conn = new ServerSocket(port);
}
catch(IOException e) {
System.out.println("Erreur à la création du serveur : "+e.getMessage());
System.exit(1);
}
game = new Game();
while (true) {
try {
comm = conn.accept();
t = new ThreadServer(game, comm);
t.start();
}
catch(IOException e) {
System.out.println("Problème de connection : "+e.getMessage());
}
}
}
}