Formatted and refactored SocketServer
This commit is contained in:
parent
0606c7af3b
commit
bf33e2c821
2 changed files with 7 additions and 2 deletions
|
@ -17,7 +17,7 @@ class ClientHandler implements Runnable {
|
|||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = in.read(buffer);
|
||||
if(bytesRead == -1){
|
||||
if (bytesRead == -1) {
|
||||
System.out.println("Client closed the Connection");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
public class SocketServer implements FrojCallable {
|
||||
protected static BlockingQueue<String> messageQueue = new LinkedBlockingQueue<>();
|
||||
private static ServerSocket serverSocket;
|
||||
|
||||
private final String EXIT_CODE = "EXIT";
|
||||
|
||||
@Override
|
||||
|
@ -23,8 +24,12 @@ public class SocketServer implements FrojCallable {
|
|||
|
||||
@Override
|
||||
public Object call(Interpreter interpreter, List<Object> arguments) {
|
||||
return startSocketServer(arguments.get(0));
|
||||
}
|
||||
|
||||
private Object startSocketServer(Object port) {
|
||||
try {
|
||||
Double param = (Double) arguments.get(0);
|
||||
Double param = (Double) port;
|
||||
final int PORT = param.intValue();
|
||||
|
||||
serverSocket = new ServerSocket(PORT);
|
||||
|
|
Loading…
Reference in a new issue