session_event.cpp 1.5 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by Longda on 2021/4/13.
//

#include "session_event.h"

17
SessionEvent::SessionEvent(ConnectionContext *client) : client_(client)
W
wangyunlai.wyl 已提交
18 19
{
}
羽飞's avatar
羽飞 已提交
20

21
SessionEvent::~SessionEvent()
W
wangyunlai.wyl 已提交
22 23
{
}
羽飞's avatar
羽飞 已提交
24

25 26 27
ConnectionContext *SessionEvent::get_client() const
{
  return client_;
羽飞's avatar
羽飞 已提交
28 29
}

W
wangyunlai.wyl 已提交
30 31 32 33 34
Session *SessionEvent::session() const
{
  return client_->session;
}

35 36 37
const char *SessionEvent::get_response() const
{
  return response_.c_str();
羽飞's avatar
羽飞 已提交
38 39
}

40 41
void SessionEvent::set_response(const char *response)
{
羽飞's avatar
羽飞 已提交
42 43 44
  set_response(response, strlen(response));
}

45 46
void SessionEvent::set_response(const char *response, int len)
{
羽飞's avatar
羽飞 已提交
47 48 49
  response_.assign(response, len);
}

50 51
void SessionEvent::set_response(std::string &&response)
{
羽飞's avatar
羽飞 已提交
52 53 54
  response_ = std::move(response);
}

55 56 57 58
int SessionEvent::get_response_len() const
{
  return response_.size();
}
羽飞's avatar
羽飞 已提交
59

60 61 62 63
char *SessionEvent::get_request_buf()
{
  return client_->buf;
}
羽飞's avatar
羽飞 已提交
64

65 66 67
int SessionEvent::get_request_buf_len()
{
  return SOCKET_BUFFER_SIZE;
W
wangyunlai.wyl 已提交
68
}