| 29 | } |
| 30 | |
| 31 | bool CConnectClientCallback::read_callback(char* data, int len) |
| 32 | { |
| 33 | (void) data; |
| 34 | (void) len; |
| 35 | |
| 36 | ctx_->nread_total++; |
| 37 | |
| 38 | if (ctx_->debug) |
| 39 | { |
| 40 | if (nwrite_ < 10) |
| 41 | std::cout << "gets(" << nwrite_ << "): " << data; |
| 42 | else if (nwrite_ % 2000 == 0) |
| 43 | std::cout << ">>ID: " << id_ << ", I: " |
| 44 | << nwrite_ << "; "<< data; |
| 45 | } |
| 46 | |
| 47 | // ����յ����������˳���Ϣ����ҲӦ�˳� |
| 48 | if (strncasecmp(data, "quit", 4) == 0) |
| 49 | { |
| 50 | // ��������������� |
| 51 | client_->format("Bye!\r\n"); |
| 52 | // �ر��첽������ |
| 53 | client_->close(); |
| 54 | return (true); |
| 55 | } |
| 56 | |
| 57 | if (nwrite_ >= ctx_->nwrite_limit) |
| 58 | { |
| 59 | if (ctx_->debug) |
| 60 | std::cout << "ID: " << id_ |
| 61 | << ", nwrite: " << nwrite_ |
| 62 | << ", nwrite_limit: " << ctx_->nwrite_limit |
| 63 | << ", quiting ..." << std::endl; |
| 64 | |
| 65 | // ������������˳���Ϣ |
| 66 | client_->format("quit\r\n"); |
| 67 | client_->close(); |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | char buf[256]; |
| 72 | snprintf(buf, sizeof(buf), "hello world: %d\n", nwrite_); |
| 73 | client_->write(buf, (int) strlen(buf)); |
| 74 | |
| 75 | // ��������������� |
| 76 | //client_->format("hello world: %d\n", nwrite_); |
| 77 | } |
| 78 | |
| 79 | return (true); |
| 80 | } |
| 81 | |
| 82 | bool CConnectClientCallback::write_callback() |
| 83 | { |
nothing calls this directly
no test coverage detected