Skip to content

Commit 170ec2d

Browse files
mint-runsmint-runs
authored andcommitted
update ServerSocketAcceptingThread.java
update version update gradle mini fix to remove socket exceptions
1 parent 5c5c003 commit 170ec2d

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
50 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
18 Bytes
Binary file not shown.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
apply plugin: 'maven'
77

88
group 'de.javasocketapi'
9-
version 'v1.6.0'
9+
version 'v1.7.0'
1010

1111
tasks.withType(JavaCompile) {
1212
options.encoding = 'UTF-8'

src/main/java/de/javasocketapi/core/ServerSocketAcceptingThread.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ public void run() {
2323
while (true) {
2424
if (this.serverSocket.isClosed()) {
2525
this.interrupt();
26-
return;
26+
break;
27+
} else {
28+
final Socket socket = this.serverSocket.accept();
29+
final Client client = new Client(socket);
30+
client.connect();
31+
this.clients.add(client);
32+
//update connectionUUID on client side
33+
final UpdateUUIDPacket updateUUIDPacket = new UpdateUUIDPacket(client.getConnectionUUID().get());
34+
client.send(updateUUIDPacket);
2735
}
28-
//initialise new client socket
29-
final Socket socket = this.serverSocket.accept();
30-
final Client client = new Client(socket);
31-
client.connect();
32-
this.clients.add(client);
33-
//update connectionUUID on client side
34-
final UpdateUUIDPacket updateUUIDPacket = new UpdateUUIDPacket(client.getConnectionUUID().get());
35-
client.send(updateUUIDPacket);
3636
}
3737
} catch (final IOException exception) {
3838
exception.printStackTrace();
@@ -53,23 +53,23 @@ public void disconnectClient(final UUID uuid) {
5353
//disconnect client
5454
this.clients.stream().filter(client -> client.getConnectionUUID().get().equals(uuid)).forEach(client -> {
5555
try {
56-
System.out.println("[SocketAPI] Client: " + client.getConnectionUUID().get() + " will be disconnected!");
56+
System.out.println("[JavaSocketAPI] Client: " + client.getConnectionUUID().get() + " will be disconnected!");
5757
client.disconnect();
58-
} catch (IOException exception) {
58+
} catch (final IOException exception) {
5959
exception.printStackTrace();
6060
}
6161
});
6262
}
6363

6464
public void disconnectAllClients() {
6565
//disconnect all clients
66-
System.out.println("[SocketAPI] All Clients will be disconnected!");
66+
System.out.println("[JavaSocketAPI] All Clients will be disconnected!");
6767
this.clients.forEach(client -> {
6868
try {
69-
if (client != null){
69+
if (client != null) {
7070
client.disconnect();
7171
}
72-
} catch (IOException exception) {
72+
} catch (final IOException exception) {
7373
exception.printStackTrace();
7474
}
7575
});

0 commit comments

Comments
 (0)