My Project
Public Types | Static Public Member Functions | Public Attributes | List of all members
NPL Class Reference

import C++ functions from ParaEngine API More...

Public Types

enum  NPLRuntimeStateType { NPLRuntimeStateType_NPL = 0, NPLRuntimeStateType_NPL_LITE, NPLRuntimeStateType_DLL, NPLRuntimeStateType_NPL_ExternalLuaState }
 The types of CNPLRuntimeState. More...
 
enum  NPLReturnCode {
  NPL_OK = 0, NPL_Error, NPL_ConnectionNotEstablished, NPL_QueueIsFull,
  NPL_StreamError, NPL_RuntimeState_NotExist, NPL_FailedToLoadFile, NPL_RuntimeState_NotReady,
  NPL_FileAccessDenied, NPL_ConnectionEstablished, NPL_UnableToResolveName, NPL_ConnectionTimeout,
  NPL_ConnectionDisconnected, NPL_ConnectionAborted, NPL_Command, NPL_WrongProtocol
}
 
enum  NPLConnectionState {
  ConnectionDisconnected, ConnectionConnecting, ConnectionConnected, ConnectionAuthenticating,
  ConnectionAuthenticated
}
 This describes the possible states of a NPLConnection object. More...
 
enum  PacketPriority {
  SYSTEM_PRIORITY, HIGH_PRIORITY, MEDIUM_PRIORITY, LOW_PRIORITY,
  NUMBER_OF_PRIORITIES
}
 These enumerations are used to describe when packets are delivered. More...
 
enum  PacketReliability {
  UNRELIABLE, UNRELIABLE_SEQUENCED, RELIABLE, RELIABLE_ORDERED,
  RELIABLE_SEQUENCED
}
 These enumerations are used to describe how packets are delivered. More...
 
enum  NPLMessageType {
  MSG_TYPE_FILE_ACTIVATION = 0, MSG_TYPE_COMMAND_BEGIN, MSG_TYPE_RESET, MSG_TYPE_EXIT,
  MSG_TYPE_TICK, MSG_TYPE_FILE_LOAD
}
 message type in NPLMessage More...
 
typedef boost::shared_ptr< CNPLRuntimeState > NPLRuntimeState_ptr
 
typedef boost::shared_ptr< NPLServerInfo > NPLServerInfo_ptr
 
typedef ParaIntrusivePtr< NPLMessage > NPLMessage_ptr
 
typedef boost::shared_ptr< NPLRuntimeAddress > NPLRuntimeAddress_ptr
 
typedef boost::shared_ptr< NPLTimer > NPLTimer_ptr
 
typedef boost::shared_ptr< CNPLConnection > NPLConnection_ptr
 
typedef boost::shared_ptr< CNPLRuntimeState > NPLRuntimeState_ptr
 
typedef boost::shared_ptr< NPLServerInfo > NPLServerInfo_ptr
 
typedef ParaIntrusivePtr< NPLMessage > NPLMessage_ptr
 
typedef ParaIntrusivePtr< NPLMsgOut > NPLMsgOut_ptr
 
typedef boost::shared_ptr< NPLRuntimeAddress > NPLRuntimeAddress_ptr
 
typedef boost::shared_ptr< NPLTimer > NPLTimer_ptr
 
typedef std::basic_string< char, std::char_traits< char >, ParaEngine::CNPLPool_Char_alloc<> > NPLString
 NPL String can be used instead of std::string, for strings which are created and deleted very regularly. More...
 
typedef ParaIntrusivePtr< NPLObjectBase > NPLObjectBase_ptr
 
typedef ParaIntrusivePtr< NPLTable > NPLTable_ptr
 
typedef ParaIntrusivePtr< NPLNumberObject > NPLNumberObject_ptr
 
typedef ParaIntrusivePtr< NPLBoolObject > NPLBoolObject_ptr
 
typedef ParaIntrusivePtr< NPLStringObject > NPLStringObject_ptr
 
typedef CNPLWriterT< ParaEngine::StringBuilderCNPLBufWriter
 using StringBuilder for buffering. More...
 
typedef CNPLWriterT< std::string > CNPLWriter
 using std::string for buffering
 

Static Public Member Functions

static string HelloWorld ()
 This function is for testing NPLMonoInterface.cs More...
 
static string GetCurrentMsg (System.IntPtr npl_runtime_state)
 Get the current incoming message of a npl_runtime_state. More...
 
static void activate (System.IntPtr npl_runtime_state, string file_name, string msg)
 activate a local or remote file More...
 
static void activate2 (string file_name, string msg)
 same as activate2. More...
 
static void accept (string tid, string nid)
 accept a given connection. More...
 
static void reject (string tid)
 reject and close a given connection. More...
 
static string HelloWorld ()
 This function is for testing NPLMonoInterface.cs More...
 
static string GetCurrentMsg (System.IntPtr npl_runtime_state)
 Get the current incoming message of a npl_runtime_state. More...
 
static void activate (System.IntPtr npl_runtime_state, string file_name, string msg)
 activate a local or remote file More...
 
static void activate2 (string file_name, string msg)
 same as activate2. More...
 
static void accept (string tid, string nid)
 accept a given connection. More...
 
static void reject (string tid)
 reject and close a given connection. More...
 

Public Attributes

const char * NPLBaseFiles []
 

Detailed Description

import C++ functions from ParaEngine API

Member Typedef Documentation

§ CNPLBufWriter

using StringBuilder for buffering.

This is the prefered way to do the code generator

§ NPLString

typedef std::basic_string<char, std::char_traits<char>, ParaEngine::CNPLPool_Char_alloc<> > NPL.NPLString

NPL String can be used instead of std::string, for strings which are created and deleted very regularly.

iternally it uses memory pool CNPLPool_Char_alloc for memory allocation. NPL String uses SSO(small string optimization 16 bytes) as std::string; for string smaller or equal to 2048 Bytes, it uses one of its internal memory pools, for even bigger string, standard malloc is used(default to std::string behavior).

Member Enumeration Documentation

§ NPLConnectionState

This describes the possible states of a NPLConnection object.

the larger the value, the later the stage.

Enumerator
ConnectionDisconnected 

socket is in disconnected state.

ConnectionConnecting 

socket is currently trying to establish a connection.

ConnectionConnected 

socket is connected to the server but authentication is not (yet) done.

ConnectionAuthenticating 

socket is connected and being authenticated

ConnectionAuthenticated 

socket is connected and authenticated

§ NPLMessageType

message type in NPLMessage

Enumerator
MSG_TYPE_FILE_ACTIVATION 

normal file activation

MSG_TYPE_EXIT 

exit the runtime state

MSG_TYPE_TICK 

frame move tick

MSG_TYPE_FILE_LOAD 

load without activation

§ NPLRuntimeStateType

The types of CNPLRuntimeState.

Enumerator
NPLRuntimeStateType_NPL 

the default NPL runtime state, with all NPL and ParaEngine functions loaded. it will consume about 1MB memory at start up.

NPLRuntimeStateType_NPL_LITE 

the light-weighter NPL runtime state, with only NPL and very limited functions loaded.

NPLRuntimeStateType_DLL 

it consumes nothing. and is usually used with DLL plugins.

NPLRuntimeStateType_NPL_ExternalLuaState 

same as NPLRuntimeStateType_NPL, but with externally set lua state

§ PacketPriority

These enumerations are used to describe when packets are delivered.

Enumerator
MEDIUM_PRIORITY 

High priority messages are send before medium priority messages.

LOW_PRIORITY 

Medium priority messages are send before low priority messages.

NUMBER_OF_PRIORITIES 

Low priority messages are only sent when no other messages are waiting.

§ PacketReliability

These enumerations are used to describe how packets are delivered.

Note
Note to self: I write this with 3 bits in the stream. If I add more remember to change that
Enumerator
UNRELIABLE_SEQUENCED 

Same as regular UDP, except that it will also discard duplicate datagrams. The network layer adds (6 to 17) + 21 bits of overhead, 16 of which is used to detect duplicate packets and 6 to 17 of which is used for message length.

RELIABLE 

Regular UDP with a sequence counter. Out of order messages will be discarded. This adds an additional 13 bits on top what is used for UNRELIABLE.

RELIABLE_ORDERED 

The message is sent reliably, but not necessarily in any order. Same overhead as UNRELIABLE.

RELIABLE_SEQUENCED 

This message is reliable and will arrive in the order you sent it. Messages will be delayed while waiting for out of order messages. Same overhead as UNRELIABLE_SEQUENCED.

This message is reliable and will arrive in the sequence you sent it. Out or order messages will be dropped. Same overhead as UNRELIABLE_SEQUENCED.

Member Function Documentation

§ accept() [1/2]

static void NPL.accept ( string  tid,
string  nid 
)
static

accept a given connection.

The connection will be regarded as authenticated once accepted.

Parameters
tidthe temporary id or NID of the connection to be accepted. usually it is from msg.tid or msg.nid.
nidif this is not nil, tid will be renamed to nid after accepted.

§ accept() [2/2]

static void NPL.accept ( string  tid,
string  nid 
)
static

accept a given connection.

The connection will be regarded as authenticated once accepted.

Parameters
tidthe temporary id or NID of the connection to be accepted. usually it is from msg.tid or msg.nid.
nidif this is not nil, tid will be renamed to nid after accepted.

§ activate() [1/2]

static void NPL.activate ( System.IntPtr  npl_runtime_state,
string  file_name,
string  msg 
)
static

activate a local or remote file

Parameters
npl_runtime_state
file_namea globally unique name of a NPL file name instance. The string format of an NPL file name is like below. [(sRuntimeStateName|gl)][sNID:]sRelativePath[] the following is a list of all valid file name combinations: "user001@paraengine.com:script/hello.lua" – a file of user001 in its default gaming thread "(world1)server001@paraengine.com:script/hello.lua" – a file of server001 in its thread world1 "(worker1)script/hello.lua" – a local file in the thread worker1 "(gl)script/hello.lua" – a glia (local) file in the current runtime state's thread "script/hello.lua" – a file in the current thread. For a single threaded application, this is usually enough. "(worker1)NPLRouter.dll" – activate a C++ or C# dll. Please note that, in windows, it looks for NPLRonter.dll; in linux, it looks for ./libNPLRouter.so "plugin/libNPLRouter.dll" – almost same as above, it is recommented to remove the heading 'lib' when loading. In windows, it looks for plugin/NPLRonter.dll; in linux, it looks for ./plugin/libNPLRouter.so
msg

§ activate() [2/2]

static void NPL.activate ( System.IntPtr  npl_runtime_state,
string  file_name,
string  msg 
)
static

activate a local or remote file

Parameters
npl_runtime_state
file_namea globally unique name of a NPL file name instance. The string format of an NPL file name is like below. [(sRuntimeStateName|gl)][sNID:]sRelativePath[] the following is a list of all valid file name combinations: "user001@paraengine.com:script/hello.lua" – a file of user001 in its default gaming thread "(world1)server001@paraengine.com:script/hello.lua" – a file of server001 in its thread world1 "(worker1)script/hello.lua" – a local file in the thread worker1 "(gl)script/hello.lua" – a glia (local) file in the current runtime state's thread "script/hello.lua" – a file in the current thread. For a single threaded application, this is usually enough. "(worker1)NPLRouter.dll" – activate a C++ or C# dll. Please note that, in windows, it looks for NPLRonter.dll; in linux, it looks for ./libNPLRouter.so "plugin/libNPLRouter.dll" – almost same as above, it is recommented to remove the heading 'lib' when loading. In windows, it looks for plugin/NPLRonter.dll; in linux, it looks for ./plugin/libNPLRouter.so
msg

§ activate2() [1/2]

static void NPL.activate2 ( string  file_name,
string  msg 
)
static

same as activate2.

except that no npl_runtime_state is specified, the main runtime state is assumed.

Parameters
file_name
msg

§ activate2() [2/2]

static void NPL.activate2 ( string  file_name,
string  msg 
)
static

same as activate2.

except that no npl_runtime_state is specified, the main runtime state is assumed.

Parameters
file_name
msg

§ GetCurrentMsg() [1/2]

static string NPL.GetCurrentMsg ( System.IntPtr  npl_runtime_state)
static

Get the current incoming message of a npl_runtime_state.

Remarks
: This function should only be called from activate() function, since activate() function runs in the same thread of its parent npl_runtime_state
Parameters
mono_scripting_state
Returns

§ GetCurrentMsg() [2/2]

static string NPL.GetCurrentMsg ( System.IntPtr  npl_runtime_state)
static

Get the current incoming message of a npl_runtime_state.

Remarks
: This function should only be called from activate() function, since activate() function runs in the same thread of its parent npl_runtime_state
Parameters
mono_scripting_state
Returns

§ HelloWorld() [1/2]

static string NPL.HelloWorld ( )
static

This function is for testing NPLMonoInterface.cs

Returns
All your monos belong to ParaEngine!

§ HelloWorld() [2/2]

static string NPL.HelloWorld ( )
static

This function is for testing NPLMonoInterface.cs

Returns
All your monos belong to ParaEngine!

§ reject() [1/2]

static void NPL.reject ( string  tid)
static

reject and close a given connection.

The connection will be closed once rejected.

Parameters
tidthe temporary id or NID of the connection to be rejected. usually it is from msg.tid or msg.nid.

§ reject() [2/2]

static void NPL.reject ( string  tid)
static

reject and close a given connection.

The connection will be closed once rejected.

Parameters
tidthe temporary id or NID of the connection to be rejected. usually it is from msg.tid or msg.nid.

Member Data Documentation

§ NPLBaseFiles

const char* NPL.NPLBaseFiles[]
Initial value:
=
{
"script/share.lua",
"NPLWebServiceClient.dll"
}

The documentation for this class was generated from the following files: