Merge branch '164-crash-on-patching-and-possibly-right-after-login' into main/gingo...
[ryzomcore.git] / snowballs2 / server / chat / src / main.cpp
blob42a13d92a644da8bfe110eb47f8028ecb3524b64
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif // HAVE_CONFIG_H
21 #ifndef SNOWBALLS_CONFIG
22 #define SNOWBALLS_CONFIG ""
23 #endif // SNOWBALLS_CONFIG
25 #ifndef SNOWBALLS_LOGS
26 #define SNOWBALLS_LOGS ""
27 #endif // SNOWBALLS_LOGS
29 // This include is mandatory to use NeL. It include NeL types.
30 #include <nel/misc/types_nl.h>
32 #include <string>
34 #include <nel/misc/debug.h>
36 // We're using the NeL Service framework, and layer 5
37 #include <nel/net/service.h>
39 #ifdef NL_OS_WINDOWS
40 #include <Windows.h>
41 #endif
43 using namespace std;
44 using namespace NLMISC;
45 using namespace NLNET;
47 /****************************************************************************
48 * Function: cbChat
49 * Callback function called when the Chat Service receive a "CHAT"
50 * message
51 ****************************************************************************/
52 void cbChat (CMessage &msgin, const std::string &serviceName, TServiceId sid)
54 string message;
56 // Extract the incoming message content from the Frontend and print it
57 msgin.serial( message );
58 nldebug( "SB: Received CHAT line: \"%s\"", message.c_str() );
60 // Prepare to send back the message.
61 CMessage msgout( "CHAT" );
62 msgout.serial( message );
65 * Send the message to all the connected Frontend.
67 CUnifiedNetwork::getInstance ()->send( "FS", msgout );
69 nldebug( "SB: Sent to every front end service CHAT line: \"%s\"", message.c_str() );
73 /****************************************************************************
74 * CallbackArray
76 * It define the functions to call when receiving a specific message
77 ****************************************************************************/
78 TUnifiedCallbackItem CallbackArray[] =
80 { "CHAT", cbChat }
84 /****************************************************************************
85 * SNOWBALLS CHAT SERVICE MAIN Function
87 * This call create a main function for the CHAT service:
89 * - based on the base service class "IService", no need to inherit from it
90 * - having the short name "CHAT"
91 * - having the long name "chat_service"
92 * - listening on an automatically allocated port (0) by the naming service
93 * - and callback actions set to "CallbackArray"
95 ****************************************************************************/
96 NLNET_SERVICE_MAIN( IService, "CHAT", "chat_service", 0, CallbackArray, SNOWBALLS_CONFIG, SNOWBALLS_LOGS )
99 /* end of file */