⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netsession.cpp

📁 这是一款2d游戏引擎
💻 CPP
字号:
/*  $Id: netsession.cpp,v 1.11 2003/07/20 22:34:40 grumbel Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include "API/Network/NetSession/netsession.h"
#include "netsession_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_NetSession construction:

CL_NetSession::CL_NetSession(const std::string &app_id)
: impl(0)
{
	impl = new CL_NetSession_Generic(app_id);
	impl->add_ref();
}

CL_NetSession::CL_NetSession(const CL_NetSession &copy)
: impl(copy.impl)
{
	if (impl) impl->add_ref();
}

CL_NetSession::~CL_NetSession()
{
	if (impl) impl->release_ref();
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetSession attributes:

CL_NetGroup &CL_NetSession::get_all()
{
	return impl->all;
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetSession signals:

CL_Signal_v1<CL_NetComputer &> &CL_NetSession::sig_computer_connected()
{
	return impl->sig_computer_connected;
}

CL_Signal_v1<CL_NetComputer &> &CL_NetSession::sig_computer_reconnected()
{
	return impl->sig_computer_reconnected;
}

CL_Signal_v1<CL_NetComputer &> &CL_NetSession::sig_computer_disconnected()
{
	return impl->sig_computer_disconnected;
}

CL_Signal_v1<CL_NetStream &> &CL_NetSession::sig_netstream_connect(const std::string &netstream)
{
	return impl->map_netstream_connect[netstream];
}

CL_Signal_v2<CL_NetPacket &, CL_NetComputer &> &CL_NetSession::sig_netpacket_receive(const std::string &packetchannel)
{
	return impl->map_netpacket_receive[packetchannel];
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetSession operators:

void CL_NetSession::start_listen(const std::string &port)
{
	impl->start_listen(port);
}

void CL_NetSession::stop_listen()
{
	impl->stop_listen();
}

CL_NetComputer CL_NetSession::connect(const CL_IPAddress &address)
{
	return impl->connect(address);
}

CL_NetComputer CL_NetSession::connect_async(const std::string &hostname, const std::string &port)
{
	return impl->connect_async(hostname, port);
}

void CL_NetSession::show_debug(bool enable)
{
	impl->show_debug = enable;
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetSession implementation:

CL_NetSession::CL_NetSession(CL_NetSession_Generic *impl)
: impl(impl)
{
	if (impl) impl->add_ref();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -