diff --git a/JChatServerV2/bin/pad/prac2/JChat$1.class b/JChatServerV2/bin/pad/prac2/JChat$1.class index e8fef6f..d203d50 100644 --- a/JChatServerV2/bin/pad/prac2/JChat$1.class +++ b/JChatServerV2/bin/pad/prac2/JChat$1.class diff --git a/JChatServerV2/bin/pad/prac2/JChat.class b/JChatServerV2/bin/pad/prac2/JChat.class index 5c8923a..111ac02 100644 --- a/JChatServerV2/bin/pad/prac2/JChat.class +++ b/JChatServerV2/bin/pad/prac2/JChat.class diff --git a/JChatServerV2/src/pad/prac2/JChat.java b/JChatServerV2/src/pad/prac2/JChat.java index a906273..568cb83 100644 --- a/JChatServerV2/src/pad/prac2/JChat.java +++ b/JChatServerV2/src/pad/prac2/JChat.java @@ -8,14 +8,19 @@ public class JChat { String ip; int port, roomSize; - Scanner in = new Scanner(System.in); + /*Scanner in = new Scanner(System.in); System.out.print("IP: "); ip = in.nextLine(); System.out.print("Port: "); port = in.nextInt(); System.out.print("Size of chatroom: "); roomSize = in.nextInt(); - in.close(); + in.close();*/ + + ip = "desktop"; + port = 3001; + roomSize = 5; + final Server serv = new Server(ip,port,roomSize); Runtime.getRuntime().addShutdownHook(new Thread() { diff --git a/QChatClient/chatroom.cpp b/QChatClient/chatroom.cpp index 2e546bb..99f7a70 100644 --- a/QChatClient/chatroom.cpp +++ b/QChatClient/chatroom.cpp @@ -342,7 +342,6 @@ void Chatroom::sendMsg() string Chatroom::getSender(string msg) { - cout << msg << endl; if(msg[0] == '@') { return msg.substr(1,msg.find(" ")-1); @@ -378,11 +377,9 @@ void Chatroom::startSession() void Chatroom::freeChats(bool active) { - int count = 0; map::iterator it; if(active) { - cout << "FREE ACTIVE (" << activeChats.size() << " remaining)" << endl; while(true) { chatMutex.lock(); @@ -392,29 +389,19 @@ void Chatroom::freeChats(bool active) { break; } - count++; ChatWindow* chat = (ChatWindow*) it->second; chat->notifyClose(); } } else { - cout << "FREE INACTIVE (" << inactiveChats.size() << " remaining)" << endl; - map::iterator it; - while(true) + for(it = inactiveChats.begin(); it != inactiveChats.end(); it++) { - it = inactiveChats.begin(); - if(it == inactiveChats.end()) - { - break; - } - count++; ChatWindow* chat = (ChatWindow*) it->second; - inactiveChats.erase(it); delete chat; } + inactiveChats.clear(); } - cout << "DELETED " << count << endl << "REMAINING" << endl << activeChats.size() << " ACTIVE" << endl << inactiveChats.size() << " INACTIVE" << endl; } Chatroom::~Chatroom() @@ -425,5 +412,3 @@ Chatroom::~Chatroom() delete send; delete ui; } - - diff --git a/QChatClient/main.cpp b/QChatClient/main.cpp index 5edec52..c8b9ca1 100644 --- a/QChatClient/main.cpp +++ b/QChatClient/main.cpp @@ -1,6 +1,20 @@ #include "loginscreen.h" #include "chatroom.h" #include +#include +#include + + +void handler(int sig) +{ + void *array[10]; + size_t size; + size = backtrace(array, 10); + fprintf(stderr, "SEGFAULT\n"); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + int main(int argc, char *argv[]) {