* @override * @param data {char*} ���������ݵ�ַ * @param len {int} ���������ݳ��� * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� */
| 66 | * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� |
| 67 | */ |
| 68 | bool read_callback(char* data, int len) { |
| 69 | if (timer_) { |
| 70 | client_->get_handle().del_timer(timer_); |
| 71 | } |
| 72 | timer_ = new read_timer(*this); |
| 73 | long long delay = 1000; |
| 74 | client_->get_handle().set_timer(timer_, delay, 0); |
| 75 | |
| 76 | i_++; |
| 77 | if (i_ < 5) { |
| 78 | std::cout << ">>gets(i:" << i_ << "): " |
| 79 | << data << std::endl; |
| 80 | } |
| 81 | |
| 82 | // ���Զ�̿ͻ���ϣ���˳�����ر�֮ |
| 83 | if (strncasecmp(data, "quit", 4) == 0) { |
| 84 | client_->format("Bye!\r\n"); |
| 85 | client_->close(); |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | // ���Զ�̿ͻ���ϣ�������Ҳ�رգ�����ֹ�첽�¼����� |
| 90 | else if (strncasecmp(data, "stop", 4) == 0) { |
| 91 | client_->format("Stop now!\r\n"); |
| 92 | client_->close(); // �ر�Զ���첽�� |
| 93 | |
| 94 | // ֪ͨ�첽����ر�ѭ������ |
| 95 | client_->get_handle().stop(); |
| 96 | } |
| 97 | |
| 98 | // ��Զ�̿ͻ��˻�д�յ������� |
| 99 | |
| 100 | client_->write(data, len); |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * @override |
nothing calls this directly
no test coverage detected