* ʵ�ָ����е��麯�����ͻ������Ķ��ɹ��ص����� * @param data {char*} ���������ݵ�ַ * @param len {int} ���������ݳ��� * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� */
| 89 | * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� |
| 90 | */ |
| 91 | bool read_callback(char* data, int len) |
| 92 | { |
| 93 | nread_cnt_++; |
| 94 | nread_ += len; |
| 95 | |
| 96 | if (nread_cnt_ <= 100 || nread_cnt_ % 1000 == 0) { |
| 97 | char buf[256]; |
| 98 | acl::safe_snprintf(buf, sizeof(buf), |
| 99 | "read len: %d, total read: %d, nread_cnt: %d", |
| 100 | len, nread_, nread_cnt_); |
| 101 | acl::meter_time(__FILE__, __LINE__, buf); |
| 102 | } |
| 103 | |
| 104 | // ���Զ�̿ͻ���ϣ���˳�����ر�֮ |
| 105 | if (strncasecmp(data, "quit", 4) == 0) { |
| 106 | client_->format("Bye!\r\n"); |
| 107 | client_->close(); |
| 108 | return true; |
| 109 | } |
| 110 | |
| 111 | // ���Զ�̿ͻ���ϣ�������Ҳ�رգ�����ֹ�첽�¼����� |
| 112 | if (strncasecmp(data, "stop", 4) == 0) { |
| 113 | client_->format("Stop now!\r\n"); |
| 114 | client_->close(); // �ر�Զ���첽�� |
| 115 | |
| 116 | // ֪ͨ�첽����ر�ѭ������ |
| 117 | client_->get_handle().stop(); |
| 118 | } |
| 119 | |
| 120 | //printf(">>data=%s\n", data); |
| 121 | // ��Զ�̿ͻ��˻�д�յ������� |
| 122 | |
| 123 | client_->write(data, len); |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * ʵ�ָ����е��麯�����ͻ�������д�ɹ��ص����� |
nothing calls this directly
no test coverage detected