3 #include <boost/bimap.hpp> 4 #include <boost/thread/shared_mutex.hpp> 8 #include "NPLMessageQueue.h" 9 #include "NPLConnection.h" 10 #include "NPLRuntimeState.h" 11 #include "util/mutex.h" 79 void NPL_accept(
const char* tid,
const char* nid = NULL);
82 void NPL_SetProtocol(
const char* nid, CNPLConnection::ProtocolType protocolType = CNPLConnection::ProtocolType::NPL);
163 int PostNetworkEvent(NPLReturnCode nNPLNetworkCode,
const char * sNid=NULL,
const char* sMsg=NULL);
169 bool IsUseCompressionIncomingConnection();
175 bool IsUseCompressionOutgoingConnection();
185 int GetCompressionLevel();
193 int GetCompressionThreshold();
208 typedef std::map<string, NPLConnection_ptr> ActiveConnectionMap_Type;
209 typedef std::map<string, NPLRuntimeAddress_ptr> ServerAddressMap_Type;
210 typedef boost::bimap<int, std::string> StringBimap_Type;
bool GetPubFileNameByID(string &filename, int nID)
get a public file name by its id in the public filename map [thread safe]
Definition: NPLDispatcher.cpp:244
NPLConnection_ptr CreateConnection(NPLRuntimeAddress_ptr pAddress)
Create a new connection with a remote server and immediately connect and start the connection...
Definition: NPLDispatcher.cpp:98
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
void RenameConnection(NPLConnection_ptr pConnection, const char *sNid)
rename a given connection.
Definition: NPLDispatcher.cpp:530
NPLConnection_ptr GetNPLConnectionByNID(const string &sNID)
same as CreateGetNPLConnectionByNID(), except that the returned connection object may be null...
Definition: NPLDispatcher.cpp:122
void RenameConnectionImp(NPLConnection_ptr pConnection, const char *sNid)
not thread safe.
Definition: NPLDispatcher.cpp:537
void SetCompressionThreshold(int nThreshold)
set the default compression threshold for all connections on this machine.
Definition: NPLDispatcher.cpp:59
this class serves as an interface between the low level socket interface and NPL message queues...
Definition: NPLDispatcher.h:23
CNPLNetServer * m_pServer
the server object
Definition: NPLDispatcher.h:249
StringBimap_Type m_public_filemap
only files in the public file map can be activated remotely.
Definition: NPLDispatcher.h:246
int m_nCompressionLevel
zlib compression level to use in case compresssion is enabled.
Definition: NPLDispatcher.h:237
bool AddNPLRuntimeAddress(NPLRuntimeAddress_ptr pAddress)
add a given NPL runtime address to the fully trusted server addresses list.
Definition: NPLDispatcher.cpp:205
NPLReturnCode Activate_Async(const NPLFileName &file_name, const char *code=NULL, int nLength=0, int priority=0)
Activate the specified remote file.
Definition: NPLDispatcher.cpp:297
void ClearPublicFiles()
clear all public files, so that the NPL server will be completely private.
Definition: NPLDispatcher.cpp:238
a globally unique name of a NPL file name instance.
Definition: NPLCommon.h:26
int m_nCompressionThreshold
when msg is larger than this, we will compress it.
Definition: NPLDispatcher.h:240
NPLRuntimeAddress_ptr GetNPLRuntimeAddress(const string &sNID)
check to see if a given NID is trusted by the dispatcher.
Definition: NPLDispatcher.cpp:194
ServerAddressMap_Type m_server_address_map
a mapping from the NPL runtime id (NID) to its full NPLRuntimeAddress.
Definition: NPLDispatcher.h:222
A NPL msg received from a socket.
Definition: NPLMsgIn.h:8
int PostNetworkEvent(NPLReturnCode nNPLNetworkCode, const char *sNid=NULL, const char *sMsg=NULL)
post network event It will post network message as {code=nNPLNetworkCode, nid=string, msg=string}
Definition: NPLDispatcher.cpp:321
bool m_bUseCompressionOutgoingConnection
whether to use compression on transport layer for outgoing connections
Definition: NPLDispatcher.h:234
void NPL_accept(const char *tid, const char *nid=NULL)
accept a given connection.
Definition: NPLDispatcher.cpp:501
NPLConnection_ptr CreateGetNPLConnectionByNID(const string &sNID)
Get the NPL connection object by a given NID.
Definition: NPLDispatcher.cpp:69
void AddNPLConnection(const string &sNID, NPLConnection_ptr pConnection)
A a new NPL connection to the m_active_connection_map.
Definition: NPLDispatcher.cpp:134
bool m_bUseCompressionIncomingConnection
whether to use compression on transport layer for incoming connections
Definition: NPLDispatcher.h:231
Current NPL configuration settings.
Definition: NPLNetServer.h:16
NPLReturnCode DispatchMsg(NPLMsgIn &msg)
Dispatch a message from a given socket connection to a local NPL runtime state.
Definition: NPLDispatcher.cpp:350
void Cleanup()
clean up all resources
Definition: NPLDispatcher.cpp:187
Definition: inftrees.h:24
void AddPublicFile(const string &filename, int nID)
add a nID, filename pair to the public file list.
Definition: NPLDispatcher.cpp:216
ActiveConnectionMap_Type m_pending_connection_map
a mapping from the not connected or authenticated NPL runtime id (NID) to its associated NPL connecti...
Definition: NPLDispatcher.h:216
void SetCompressionLevel(int nLevel)
Set the zlib compression level to use in case compresssion is enabled.
Definition: NPLDispatcher.cpp:49
void SetUseCompressionIncomingConnection(bool bCompressIncoming)
whether to use compression on transport layer for incoming connections
Definition: NPLDispatcher.cpp:29
void NPL_SetProtocol(const char *nid, CNPLConnection::ProtocolType protocolType=CNPLConnection::ProtocolType::NPL)
set transmission protocol, default value is 0.
Definition: NPLDispatcher.cpp:521
ActiveConnectionMap_Type m_active_connection_map
a mapping from the authenticated NPL runtime id (NID) to its associated NPL connection.
Definition: NPLDispatcher.h:213
bool RemoveNPLConnection(NPLConnection_ptr pConnection)
remove a given connection object from the active or pending connection map if any.
Definition: NPLDispatcher.cpp:161
cross platform mutex
Definition: mutex.h:95
ParaEngine::mutex m_mutex
provide thread safe access to shared data members in this class.
Definition: NPLDispatcher.h:228
void SetUseCompressionOutgoingConnection(bool bCompressOutgoing)
whether to use compression on transport layer for outgoing connections
Definition: NPLDispatcher.cpp:39
int GetIDByPubFileName(const string &sString)
get id by filename string in the public filename map [thread safe]
Definition: NPLDispatcher.cpp:256
CNPLNetServer * GetNetServer()
the NPL Net server object.
Definition: NPLDispatcher.h:30
bool CheckPubFile(string &filename, int &nID)
return true if either filename or nID is in the public file list.
Definition: NPLDispatcher.cpp:270