diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html')
-rw-r--r-- | cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html b/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html new file mode 100644 index 00000000..eb84b26f --- /dev/null +++ b/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html @@ -0,0 +1,253 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> +<HEAD><style> A { color:black }</style> +<!-- hennerik CVSweb $Revision: 1.93 $ --> +<TITLE>code/nelns/admin_service/admin_service.cpp - view - 1.2</TITLE></HEAD> +<BODY BGCOLOR="#eeeeee"> +<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="admin_service.cpp"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="admin_service.cpp">admin_service.cpp</A> + CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/">admin_service</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/">admin_service</a> / <a href="/cvs/cvsweb.cgi/code/nelns/admin_service/admin_service.cpp">admin_service.cpp</a> (<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nelns/admin_service/admin_service.cpp?rev=1.2" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nelns/admin_service/admin_service.cpp?rev=1.2','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR> +Revision <B>1.2</B>, <i>Thu May 3 13:19:13 2001 UTC</i> (14 months, 3 weeks ago) by <i>lecroart</i> +<BR>Branch: <b>MAIN</b> +<BR>Changes since <b>1.1: +2 -6 + lines</b><PRE> +BUGFIX: now compile on linux +</PRE> +</td></tr></table><HR noshade><PRE>/** \file admin_service.cpp + * Admin Service (AS) + * + * $Id: admin_service.cpp,v 1.2 2001/05/03 13:19:13 lecroart Exp $ + * + */ + +/* Copyright, 2000 Nevrax Ltd. + * + * This file is part of NEVRAX D.T.C. SYSTEM. + * NEVRAX D.T.C. SYSTEM 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, or (at your option) + * any later version. + * + * NEVRAX D.T.C. SYSTEM 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 NEVRAX D.T.C. SYSTEM; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#include <string> +#include <list> + +#include "nel/net/service.h" +#include "nel/misc/debug.h" +#include "nel/misc/config_file.h" + +#include "nel/net/net_manager.h" + + +using namespace std; +using namespace NLMISC; +using namespace NLNET; + + +struct CService +{ + CService(TSockId s) : AESSockId(s), AESId(NextAESId++) { } + + TSockId AESSockId; // TSockId of the AES that have this service + uint32 AESId; // TSockId of the AES that have this service + uint32 SId; // uint32 to identify the service + string ShortName; + string LongName; + +private: + + static uint32 NextAESId; +}; + +uint32 CService::NextAESId = 0; + +list<CService> Services; +typedef list<CService>::iterator sit; + +sit find (TSockId aesid, uint32 sid) +{ + sit it; + for (it = Services.begin(); it != Services.end(); it++) + { + if ((*it).AESSockId== aesid && (*it).SId == sid) break; + } + return it; +} + +sit find (uint32 aesid, uint32 sid) +{ + sit it; + for (it = Services.begin(); it != Services.end(); it++) + { + if ((*it).AESId == aesid && (*it).SId == sid) break; + } + return it; +} + +/* +NLMISC_COMMAND (start, "start a service", "<service_name>") +{ + if(args.size() != 1 && args.size() != 2) return false; + + CMessage msgout (CNetManager::getSIDA("AES"), "ESC"); + msgout.serial (args[1]); + + uint8 background = 0; + + if (args.size() == 2) + { + if (args[1] == "&") + uint8 background = 1; + else + return false; + } + + msgout.serial (background); + CNetManager::send ("AES", msgout); + return true; +} + + +CLog logstdout; +CStdDisplayer dispstdout; + +NLMISC_COMMAND (stop, "stop a service", "<aesid> <sid>") +{ + if(args.size() != 3) return false; + + CMessage msgout (CNetManager::getSIDA("AES"), "SS"); + msgout.serial (args[2]); + CNetManager::send ("AES", msgout); +} +*/ + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////// CONNECTION TO THE AES /////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// + + +static void cbExecuteSystemCommandResult (CMessage& msgin, TSockId from, CCallbackNetBase &netbase) +{ + vector<string> result; + msgin.serialCont (result); + + nlinfo("command result"); + for (uint i = 0; i < result.size(); i++) + { + printf ("%s", result[i].c_str()); + } + nlinfo("end of command result"); +} + +static void cbServiceIdentification (CMessage& msgin, TSockId from, CCallbackNetBase &netbase) +{ + string ShortName, LongName; + + msgin.serial (ShortName); + msgin.serial (LongName); + + nlinfo ("%s %s %s is identified", from->asString().c_str(), ShortName.c_str(), LongName.c_str()); +} + +static void cbServiceReady (CMessage& msgin, TSockId from, CCallbackNetBase &netbase) +{ + string ShortName, LongName; + + msgin.serial (ShortName); + msgin.serial (LongName); + + nlinfo ("%s %s %s is ready", from->asString().c_str(), ShortName.c_str(), LongName.c_str()); +} + +static void cbServiceConnection (CMessage& msgin, TSockId from, CCallbackNetBase &netbase) +{ + nlinfo ("%s a service is connected", from->asString().c_str()); +} + +static void cbServiceDisconnection (CMessage& msgin, TSockId from, CCallbackNetBase &netbase) +{ + string ShortName, LongName; + + msgin.serial (ShortName); + msgin.serial (LongName); + + nlinfo ("%s %s %s is disconnected", from->asString().c_str(), ShortName.c_str(), LongName.c_str()); +} + + +TCallbackItem AESCallbackArray[] = +{ + { "ESCR", cbExecuteSystemCommandResult }, + + { "SID", cbServiceIdentification }, + { "SR", cbServiceReady }, + { "SC", cbServiceConnection }, + { "SD", cbServiceDisconnection }, +}; + + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////// CONNECTION TO THE CLIENT //////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +void clientConnection (const string &serviceName, TSockId from, void *arg) +{ + // new client, send him all out info about services + + nlinfo ("client %s is connected", from->asString().c_str()); + + CMessage msgout (CNetManager::getSIDA ("AESAS"), "SL"); + uint32 size = (uint32)Services.size(); + msgout.serial (size); + for (sit it = Services.begin(); it != Services.end(); it++) + { + msgout.serial ((*it).AESId); + msgout.serial ((*it).SId); + msgout.serial ((*it).ShortName); + msgout.serial ((*it).LongName); + } + CNetManager::send ("AS", msgout, from); +} + +TCallbackItem ASCallbackArray[] = +{ + { "", NULL }, +}; + +class CAdminService : public IService +{ +public: + + /// Init the service, load the universal time. + void init () + { + CNetManager::setConnectionCallback ("AS", clientConnection, NULL); + + // connec to the AES + CNetManager::addClient ("AES", "localhost:49996"); + CNetManager::addCallbackArray ("AES", AESCallbackArray, sizeof (AESCallbackArray)/sizeof(AESCallbackArray[0])); + + } + + bool update () + { + return true; + } +}; + + +/// Naming Service +NLNET_SERVICE_MAIN (CAdminService, "AS", "admin_service", 49995, ASCallbackArray); +</PRE>
\ No newline at end of file |