-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.java
61 lines (58 loc) · 1.8 KB
/
Server.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
52
53
54
55
56
57
58
59
60
61
package maze;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
/**
* Group Members: Connor Allen, Cameron White, Liel van der Hoeven
* @author Liel van der Hoeven
*/
public class Server
{
ServerSocket providerSocket;
Socket connection = null;
ObjectOutputStream out;
ObjectInputStream in;
String ratposition;
GUI g = new GUI();
public void run() throws ClassNotFoundException, InterruptedException
{
try
{
String move;
int count = 0;
int maxcount = 50000;
providerSocket = new ServerSocket(13000);
System.out.println("Waiting for Client to connect...");
connection = providerSocket.accept();
out = new ObjectOutputStream(connection.getOutputStream());
out.flush();
in = new ObjectInputStream(connection.getInputStream());
do
{
ratposition = (String)in.readObject();
System.out.println(ratposition);
move = g.getString(ratposition);
System.out.println(move);
if(ratposition.equals("ppwwpworo"))
{
move = "ooooooooo";
}
if(count == maxcount)
{
move = "wwwwwwwww";
}
out.writeObject(move);
count++;
}while(!ratposition.equals("ppwwpworo"));
out.close();
in.close();
providerSocket.close();
}
catch(IOException ioException)
{
ioException.printStackTrace();
}
}
}