/*  $Id: netobject_server.cpp,v 1.8 2003/08/14 23:01:33 mbn 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/NetObjects/netobject_server.h"
#include "API/Network/NetObjects/netobject_controller.h"
#include "netobject_server_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_NetObject_Server construction:

CL_NetObject_Server::CL_NetObject_Server(CL_NetObject_Controller *controller)
: impl(0)
{
	impl = new CL_NetObject_Server_Generic(controller->impl);
	impl->add_ref();
}

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

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

/////////////////////////////////////////////////////////////////////////////
// CL_NetObject_Server attributes:

int CL_NetObject_Server::get_obj_id() const
{
	return impl->obj_id;
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetObject_Server operations:

void CL_NetObject_Server::send(CL_NetGroup &group, int msg_type, const CL_NetPacket &message)
{
	impl->send(group, msg_type, message);
}

void CL_NetObject_Server::send(CL_NetComputer &computer, int msg_type, const CL_NetPacket &message)
{
	impl->send(computer, msg_type, message);
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetObject_Server signals:

CL_Signal_v2<CL_NetComputer &, CL_NetPacket &> &CL_NetObject_Server::sig_received_message(int msg_type)
{
	return impl->sig_received_message[msg_type];
}

/////////////////////////////////////////////////////////////////////////////
// CL_NetObject_Server implementation:
