2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* charybdis: A useful ircd.
|
|
|
|
* client.h: The ircd client header.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2004 ircd-ratbox development team
|
|
|
|
* Copyright (C) 2005 William Pitcock and Jilles Tjoelker
|
2016-08-24 01:08:40 +02:00
|
|
|
* Copyright (C) 2005-2016 Charybdis Development Team
|
2007-01-25 07:40:21 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_CLIENT_H
|
2016-08-24 00:25:09 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd
|
|
|
|
{
|
|
|
|
struct client;
|
|
|
|
|
|
|
|
const char *write(client &, const char *&start, const char *const &stop);
|
|
|
|
char *read(client &, char *&start, char *const &stop);
|
2017-09-30 08:04:41 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
http::response::write_closure write_closure(client &);
|
|
|
|
parse::read_closure read_closure(client &);
|
2017-09-30 08:04:41 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
std::shared_ptr<client> add_client(std::shared_ptr<socket>); // Creates a client.
|
|
|
|
}
|
2016-09-12 23:07:46 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
struct ircd::client
|
2017-08-23 22:33:31 +02:00
|
|
|
:std::enable_shared_from_this<client>
|
2016-09-12 23:07:46 +02:00
|
|
|
{
|
2016-11-29 16:23:38 +01:00
|
|
|
struct init;
|
2017-09-30 08:04:41 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
using list = std::list<client *>;
|
2016-09-23 08:59:24 +02:00
|
|
|
|
2016-11-29 16:23:38 +01:00
|
|
|
static list clients;
|
2016-09-23 08:59:24 +02:00
|
|
|
|
2017-08-23 23:13:57 +02:00
|
|
|
unique_const_iterator<list> clit;
|
2016-11-29 16:23:38 +01:00
|
|
|
std::shared_ptr<socket> sock;
|
2017-09-24 04:46:17 +02:00
|
|
|
ircd::timer request_timer;
|
2016-09-23 08:59:24 +02:00
|
|
|
|
2017-03-11 02:46:25 +01:00
|
|
|
bool main() noexcept;
|
2016-09-23 08:59:24 +02:00
|
|
|
|
2016-11-29 16:23:38 +01:00
|
|
|
public:
|
2017-03-14 00:11:30 +01:00
|
|
|
client(std::shared_ptr<socket>);
|
2017-09-30 08:04:41 +02:00
|
|
|
client(const hostport &, const seconds &timeout = 5s);
|
2017-03-11 02:46:25 +01:00
|
|
|
client();
|
2016-11-29 16:23:38 +01:00
|
|
|
client(client &&) = delete;
|
|
|
|
client(const client &) = delete;
|
|
|
|
client &operator=(client &&) = delete;
|
|
|
|
client &operator=(const client &) = delete;
|
|
|
|
virtual ~client() noexcept;
|
2017-08-28 23:51:22 +02:00
|
|
|
|
2017-09-30 08:04:41 +02:00
|
|
|
friend hostport remote(const client &);
|
|
|
|
friend hostport local(const client &);
|
2016-09-23 08:59:24 +02:00
|
|
|
};
|
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
struct ircd::client::init
|
2016-08-28 10:16:24 +02:00
|
|
|
{
|
2016-11-29 16:23:38 +01:00
|
|
|
init();
|
|
|
|
~init() noexcept;
|
|
|
|
};
|