Nearly finished client side logging
Client/src/logging/ClientLogger.java:
-added printConfiramtion method
Client/src/networking/Client.java:
- swapped out.println with clientLogger.printConfirmation
This commit is contained in:
4
.idea/artifacts/Client_jar.xml
generated
4
.idea/artifacts/Client_jar.xml
generated
@@ -1,8 +1,8 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="Client:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/Client_jar</output-path>
|
||||
<root id="archive" name="ArcadeMachine.jar">
|
||||
<element id="module-output" name="ArcadeMachine" />
|
||||
<root id="archive" name="Client.jar">
|
||||
<element id="module-output" name="Client" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
8
.idea/artifacts/Server_jar.xml
generated
Normal file
8
.idea/artifacts/Server_jar.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="Server:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/Server_jar</output-path>
|
||||
<root id="archive" name="Server.jar">
|
||||
<element id="module-output" name="Server" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
3
Client/src/META-INF/MANIFEST.MF
Normal file
3
Client/src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: networking.Client
|
||||
|
||||
@@ -44,4 +44,12 @@ public class ClientLogger {
|
||||
public void printLog(String message, boolean success, LogType logType){
|
||||
this.printLog(message, "server", success, logType);
|
||||
}
|
||||
|
||||
public void printConfirmation(int code){
|
||||
if (code == 200){
|
||||
printLog(" Status: sent!", true, LogType.Log);
|
||||
} else {
|
||||
printLog(" Status: not sent!", false, LogType.Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package networking;
|
||||
|
||||
import logging.ClientLogger;
|
||||
import logging.LogType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -18,10 +17,6 @@ public class Client {
|
||||
private String serverName;
|
||||
private boolean success;
|
||||
|
||||
public static final String ANSI_RESET = "\u001B[0m";
|
||||
public static final String ANSI_CYAN = "\u001B[36m";
|
||||
|
||||
|
||||
public Client(String ip, int port, String name) {
|
||||
try {
|
||||
scanner = new Scanner(System.in);
|
||||
@@ -39,13 +34,12 @@ public class Client {
|
||||
|
||||
public void handshake() {
|
||||
try {
|
||||
out.writeInt(15315);
|
||||
out.writeInt(165313125);
|
||||
out.flush();
|
||||
success = in.readInt() == 200;
|
||||
if (success){
|
||||
out.writeUTF(name);
|
||||
serverName = in.readUTF();
|
||||
System.out.println(serverName);
|
||||
clientLogger.printLog("You successfully connected to me", serverName, success, LogType.Log);
|
||||
} else {
|
||||
clientLogger.printLog("Connection failed try again", success, LogType.Log);
|
||||
@@ -62,9 +56,11 @@ public class Client {
|
||||
String message = scanner.nextLine();
|
||||
try {
|
||||
out.writeUTF(message);
|
||||
System.out.println(in.readInt());
|
||||
clientLogger.printConfirmation(in.readInt());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
if(message.equalsIgnoreCase("exit()"))
|
||||
break;
|
||||
|
||||
3
Server/src/META-INF/MANIFEST.MF
Normal file
3
Server/src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: networking.Server
|
||||
|
||||
3
out/production/Client/META-INF/MANIFEST.MF
Normal file
3
out/production/Client/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: networking.Client
|
||||
|
||||
3
out/production/Server/META-INF/MANIFEST.MF
Normal file
3
out/production/Server/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: networking.Server
|
||||
|
||||
Reference in New Issue
Block a user