Skip to content
Snippets Groups Projects
Commit fe070f8a authored by WinJ's avatar WinJ
Browse files

Merge remote-tracking branch 'origin/master'

parents 618a2787 6e9e5ee2
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ dependencies { ...@@ -25,6 +25,7 @@ dependencies {
test { test {
useJUnitPlatform() useJUnitPlatform()
maxHeapSize = "4096m"
} }
java { java {
......
package chat; package chat;
import javax.swing.*;
import java.io.*; import java.io.*;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
...@@ -72,12 +73,12 @@ public class UMessageServerConnection extends Thread { ...@@ -72,12 +73,12 @@ public class UMessageServerConnection extends Thread {
try { try {
cmd = cmd.trim(); cmd = cmd.trim();
switch (cmd) { switch (cmd) {
case "MAIN": case "MAIN":
m_channel(UMessageServerConnection.CHAT_CHANNEL, text); m_channel(UMessageServerConnection.CHAT_CHANNEL, text);
break; break;
default: default:
String[] parts = text.split(" ", 2); String[] parts = text.split(" ", 2);
cmd = parts[0].trim(); cmd = parts[0].trim();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -112,34 +113,52 @@ public class UMessageServerConnection extends Thread { ...@@ -112,34 +113,52 @@ public class UMessageServerConnection extends Thread {
while ((line = this.in.readLine()) != null) { while ((line = this.in.readLine()) != null) {
if (line.startsWith("PING")) { if (line.startsWith("PING")) {
write("PONG", line.substring(5)); write("PONG", line.substring(5));
} } else if (line.split(" ")[1].trim().equals("353")) {
else if (line.startsWith(":umessage")) {
int code = Integer.parseInt(line.split(" ")[1]); int code = Integer.parseInt(line.split(" ")[1]);
switch (code) { switch (code) {
// List of users... // List of users...
case IRCCodes.RplNamReply: case IRCCodes.RplNamReply:
String[] names = line.split(":")[2].split(" "); String[] names = line.split(":")[2].split(" ");
this.main.window.addUsers(names); SwingUtilities.invokeLater(new Runnable() {
break; @Override
public void run() {
main.window.addUsers(names);
}
});
break;
} }
} } else {
else {
String cmd = line.split(" ")[1]; String cmd = line.split(" ")[1];
final String[] lineParts = line.split(":");
switch (cmd) { switch (cmd) {
case "PART": case "PART":
this.main.window.removeUser(line.split(":")[1].split("!")[0]); SwingUtilities.invokeLater(new Runnable() {
break; @Override
case "JOIN": public void run() {
this.main.window.addUser(line.split(":")[1].split("!")[0]); main.window.removeUser(lineParts[1].split("!")[0]);
break; }
case "PRIVMSG": });
if (!line.split(" ")[2].equals(this.username)) { break;
return; case "JOIN":
} SwingUtilities.invokeLater(new Runnable() {
String[] lineParts = line.split(":"); @Override
this.main.window.gotMessage(lineParts[1].split("!")[0], public void run() {
lineParts[2]); main.window.addUser(lineParts[1].split("!")[0]);
break; }
});
break;
case "PRIVMSG":
if (!line.split(" ")[2].equals(this.username)) {
return;
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
main.window.gotMessage(lineParts[1].split("!")[0],
lineParts[2]);
}
});
break;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment