Commit 943f372e6eda45732dfa7f3d7e45467723f0e233
1 parent
03118b9a
git-svn-id: svn://imanolbarba.net/PAD@52 c2ee353e-ed0d-4329-bf56-03aec153487f
Showing
5 changed files
with
23 additions
and
19 deletions
JChatServerV2/bin/pad/prac2/JChat$1.class
No preview for this file type
JChatServerV2/bin/pad/prac2/JChat.class
No preview for this file type
JChatServerV2/src/pad/prac2/JChat.java
... | ... | @@ -8,14 +8,19 @@ public class JChat |
8 | 8 | { |
9 | 9 | String ip; |
10 | 10 | int port, roomSize; |
11 | - Scanner in = new Scanner(System.in); | |
11 | + /*Scanner in = new Scanner(System.in); | |
12 | 12 | System.out.print("IP: "); |
13 | 13 | ip = in.nextLine(); |
14 | 14 | System.out.print("Port: "); |
15 | 15 | port = in.nextInt(); |
16 | 16 | System.out.print("Size of chatroom: "); |
17 | 17 | roomSize = in.nextInt(); |
18 | - in.close(); | |
18 | + in.close();*/ | |
19 | + | |
20 | + ip = "desktop"; | |
21 | + port = 3001; | |
22 | + roomSize = 5; | |
23 | + | |
19 | 24 | final Server serv = new Server(ip,port,roomSize); |
20 | 25 | Runtime.getRuntime().addShutdownHook(new Thread() |
21 | 26 | { | ... | ... |
QChatClient/chatroom.cpp
... | ... | @@ -342,7 +342,6 @@ void Chatroom::sendMsg() |
342 | 342 | |
343 | 343 | string Chatroom::getSender(string msg) |
344 | 344 | { |
345 | - cout << msg << endl; | |
346 | 345 | if(msg[0] == '@') |
347 | 346 | { |
348 | 347 | return msg.substr(1,msg.find(" ")-1); |
... | ... | @@ -378,11 +377,9 @@ void Chatroom::startSession() |
378 | 377 | |
379 | 378 | void Chatroom::freeChats(bool active) |
380 | 379 | { |
381 | - int count = 0; | |
382 | 380 | map<string,void*>::iterator it; |
383 | 381 | if(active) |
384 | 382 | { |
385 | - cout << "FREE ACTIVE (" << activeChats.size() << " remaining)" << endl; | |
386 | 383 | while(true) |
387 | 384 | { |
388 | 385 | chatMutex.lock(); |
... | ... | @@ -392,29 +389,19 @@ void Chatroom::freeChats(bool active) |
392 | 389 | { |
393 | 390 | break; |
394 | 391 | } |
395 | - count++; | |
396 | 392 | ChatWindow* chat = (ChatWindow*) it->second; |
397 | 393 | chat->notifyClose(); |
398 | 394 | } |
399 | 395 | } |
400 | 396 | else |
401 | 397 | { |
402 | - cout << "FREE INACTIVE (" << inactiveChats.size() << " remaining)" << endl; | |
403 | - map<string,void*>::iterator it; | |
404 | - while(true) | |
398 | + for(it = inactiveChats.begin(); it != inactiveChats.end(); it++) | |
405 | 399 | { |
406 | - it = inactiveChats.begin(); | |
407 | - if(it == inactiveChats.end()) | |
408 | - { | |
409 | - break; | |
410 | - } | |
411 | - count++; | |
412 | 400 | ChatWindow* chat = (ChatWindow*) it->second; |
413 | - inactiveChats.erase(it); | |
414 | 401 | delete chat; |
415 | 402 | } |
403 | + inactiveChats.clear(); | |
416 | 404 | } |
417 | - cout << "DELETED " << count << endl << "REMAINING" << endl << activeChats.size() << " ACTIVE" << endl << inactiveChats.size() << " INACTIVE" << endl; | |
418 | 405 | } |
419 | 406 | |
420 | 407 | Chatroom::~Chatroom() |
... | ... | @@ -425,5 +412,3 @@ Chatroom::~Chatroom() |
425 | 412 | delete send; |
426 | 413 | delete ui; |
427 | 414 | } |
428 | - | |
429 | - | ... | ... |
QChatClient/main.cpp
1 | 1 | #include "loginscreen.h" |
2 | 2 | #include "chatroom.h" |
3 | 3 | #include <QApplication> |
4 | +#include <signal.h> | |
5 | +#include <execinfo.h> | |
6 | + | |
7 | + | |
8 | +void handler(int sig) | |
9 | +{ | |
10 | + void *array[10]; | |
11 | + size_t size; | |
12 | + size = backtrace(array, 10); | |
13 | + fprintf(stderr, "SEGFAULT\n"); | |
14 | + backtrace_symbols_fd(array, size, STDERR_FILENO); | |
15 | + exit(1); | |
16 | +} | |
17 | + | |
4 | 18 | |
5 | 19 | int main(int argc, char *argv[]) |
6 | 20 | { | ... | ... |