MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | Protected 属性 | Private 成员函数 | 所有成员列表
PlainCommunicator类 参考

与客户端进行通讯 更多...

#include <plain_communicator.h>

类 PlainCommunicator 继承关系图:
Communicator CliCommunicator

Public 成员函数

RC read_event (SessionEvent *&event) override
 监听到有新的数据到达,调用此函数进行接收消息 如果需要创建新的任务来处理,那么就创建一个SessionEvent 对象并通过event参数返回。 更多...
 
RC write_result (SessionEvent *event, bool &need_disconnect) override
 在任务处理完成后,通过此接口将结果返回给客户端 更多...
 
- Public 成员函数 继承自 Communicator
virtual RC init (int fd, Session *session, const std::string &addr)
 接收到一个新的连接时,进行初始化 更多...
 
virtual RC read_event (SessionEvent *&event)=0
 监听到有新的数据到达,调用此函数进行接收消息 如果需要创建新的任务来处理,那么就创建一个SessionEvent 对象并通过event参数返回。 更多...
 
virtual RC write_result (SessionEvent *event, bool &need_disconnect)=0
 在任务处理完成后,通过此接口将结果返回给客户端 更多...
 
Sessionsession () const
 关联的会话信息
 
struct event & read_event ()
 libevent使用的数据,参考server.cpp
 
const char * addr () const
 对端地址 如果是unix socket,可能没有意义
 

Protected 属性

std::vector< char > send_message_delimiter_
 发送消息分隔符
 
std::vector< char > debug_message_prefix_
 调试信息前缀
 
- Protected 属性 继承自 Communicator
Sessionsession_ = nullptr
 
struct event read_event_
 
std::string addr_
 
BufferedWriterwriter_ = nullptr
 
int fd_ = -1
 

Private 成员函数

RC write_state (SessionEvent *event, bool &need_disconnect)
 
RC write_debug (SessionEvent *event, bool &need_disconnect)
 
RC write_result_internal (SessionEvent *event, bool &need_disconnect)
 

详细描述

与客户端进行通讯

使用简单的文本通讯协议,每个消息使用'\0'结尾

成员函数说明

◆ read_event()

RC PlainCommunicator::read_event ( SessionEvent *&  event)
overridevirtual

监听到有新的数据到达,调用此函数进行接收消息 如果需要创建新的任务来处理,那么就创建一个SessionEvent 对象并通过event参数返回。

实现了 Communicator.

◆ write_result()

RC PlainCommunicator::write_result ( SessionEvent event,
bool &  need_disconnect 
)
overridevirtual

在任务处理完成后,通过此接口将结果返回给客户端

参数
event任务数据,包括处理的结果
need_disconnect是否需要断开连接
返回
处理结果。即使返回不是SUCCESS,也不能直接断开连接,需要通过need_disconnect来判断 是否需要断开连接

实现了 Communicator.


该类的文档由以下文件生成: