MCPcopy Create free account
hub / github.com/acl-dev/acl / read_callback

Method read_callback

lib_acl_cpp/samples/aio/server_timer/main.cpp:68–102  ·  view source on GitHub ↗

* @override * @param data {char*} ���������ݵ�ַ * @param len {int} ���������ݳ��� * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� */

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

strncasecmpFunction · 0.85
del_timerMethod · 0.80
set_timerMethod · 0.80
get_handleMethod · 0.45
formatMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected