From 943f372e6eda45732dfa7f3d7e45467723f0e233 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Tue, 7 Jan 2014 05:03:25 +0000 Subject: [PATCH] git-svn-id: svn://imanolbarba.net/PAD@52 c2ee353e-ed0d-4329-bf56-03aec153487f --- JChatServerV2/bin/pad/prac2/JChat$1.class | Bin 774 -> 0 bytes JChatServerV2/bin/pad/prac2/JChat.class | Bin 1315 -> 0 bytes JChatServerV2/src/pad/prac2/JChat.java | 9 +++++++-- QChatClient/chatroom.cpp | 19 ++----------------- QChatClient/main.cpp | 14 ++++++++++++++ 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/JChatServerV2/bin/pad/prac2/JChat$1.class b/JChatServerV2/bin/pad/prac2/JChat$1.class index e8fef6f..d203d50 100644 Binary files a/JChatServerV2/bin/pad/prac2/JChat$1.class and b/JChatServerV2/bin/pad/prac2/JChat$1.class differ diff --git a/JChatServerV2/bin/pad/prac2/JChat.class b/JChatServerV2/bin/pad/prac2/JChat.class index 5c8923a..111ac02 100644 Binary files a/JChatServerV2/bin/pad/prac2/JChat.class and b/JChatServerV2/bin/pad/prac2/JChat.class differ 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[]) { -- libgit2 0.22.2