92 if(!m_config.m_pcommands_handler)
94 LOG_ERROR_CC(m_conn_context,
"Command handler not set!");
97 m_cach_in_buffer.append((
const char*)ptr, cb);
99 bool is_continue =
true;
104 case conn_state_reading_head:
109 LOG_ERROR_CC(m_conn_context,
"Signature mismatch on accepted connection");
116#if BYTE_ORDER == LITTLE_ENDIAN
129 LOG_ERROR_CC(m_conn_context,
"Signature mismatch on accepted connection");
132 m_current_head = phead;
135 m_state = conn_state_reading_body;
137 case conn_state_reading_body:
138 if(m_cach_in_buffer.size() < m_current_head.m_cb)
144 std::string buff_to_invoke;
145 if(m_cach_in_buffer.size() == m_current_head.m_cb)
146 buff_to_invoke.swap(m_cach_in_buffer);
149 buff_to_invoke.assign(m_cach_in_buffer, 0, (std::string::size_type)m_current_head.m_cb);
150 m_cach_in_buffer.erase(0, (std::string::size_type)m_current_head.m_cb);
154 if(m_current_head.m_have_to_return_data)
156 std::string return_buff;
157 m_current_head.m_return_code = m_config.m_pcommands_handler->invoke(m_current_head.m_command, buff_to_invoke, return_buff, m_conn_context);
158 m_current_head.m_cb = return_buff.size();
159 m_current_head.m_have_to_return_data =
false;
160 std::string send_buff((
const char*)&m_current_head,
sizeof(m_current_head));
161 send_buff += return_buff;
163 if(!m_psnd_hndlr->do_send(send_buff.data(), send_buff.size()))
168 m_config.m_pcommands_handler->notify(m_current_head.m_command, buff_to_invoke, m_conn_context);
170 m_state = conn_state_reading_head;
173 LOG_ERROR_CC(m_conn_context,
"Undefined state in levin_server_impl::connection_handler, m_state=" << m_state);