big socket refactor
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.Instant;
|
||||
|
||||
import network.SocketWriter;
|
||||
import network.Socket;
|
||||
import network.protocol.Packet;
|
||||
import network.protocol.PacketVisitor;
|
||||
import network.protocol.packets.*;
|
||||
@@ -15,13 +14,13 @@ public class ServerConnexion implements PacketVisitor {
|
||||
|
||||
private final Server server;
|
||||
private final InetSocketAddress clientAddress;
|
||||
private final SocketWriter writer;
|
||||
private final Socket socket;
|
||||
private String chatterName;
|
||||
|
||||
public ServerConnexion(Server server, DatagramSocket socket, InetSocketAddress clientAddress) {
|
||||
public ServerConnexion(Server server, Socket socket, InetSocketAddress clientAddress) {
|
||||
this.clientAddress = clientAddress;
|
||||
this.server = server;
|
||||
this.writer = new SocketWriter(socket);
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public String getChatterName() {
|
||||
@@ -30,7 +29,7 @@ public class ServerConnexion implements PacketVisitor {
|
||||
|
||||
public void sendPacket(Packet packet) {
|
||||
try {
|
||||
this.writer.sendPacket(packet, clientAddress);
|
||||
this.socket.sendPacket(packet, clientAddress);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
this.server.removeConnexion(this);
|
||||
|
||||
Reference in New Issue
Block a user