本文整理汇总了C++中CScriptArgReader::ReadIfNextIsNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptArgReader::ReadIfNextIsNumber方法的具体用法?C++ CScriptArgReader::ReadIfNextIsNumber怎么用?C++ CScriptArgReader::ReadIfNextIsNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptArgReader
的用法示例。
在下文中一共展示了CScriptArgReader::ReadIfNextIsNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FetchRemote
// Call a function on a remote server
int CLuaFunctionDefs::FetchRemote ( lua_State* luaVM )
{
// bool fetchRemote ( string URL [, int connectionAttempts = 10, int connectTimeout = 10000 ], callback callbackFunction, [ string postData, bool bPostBinary, arguments... ] )
CScriptArgReader argStream ( luaVM );
SString strURL; CLuaFunctionRef iLuaFunction; SString strPostData; bool bPostBinary; CLuaArguments args; uint uiConnectionAttempts; uint uiConnectTimeoutMs;
argStream.ReadString ( strURL );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 );
argStream.ReadFunction ( iLuaFunction );
argStream.ReadString ( strPostData, "" );
argStream.ReadBool ( bPostBinary, false );
argStream.ReadLuaArguments ( args );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
g_pGame->GetRemoteCalls ()->Call ( strURL, &args, strPostData, bPostBinary, luaMain, iLuaFunction, uiConnectionAttempts, uiConnectTimeoutMs );
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: CallRemote
// Call a function on a remote server
int CLuaFunctionDefs::CallRemote ( lua_State* luaVM )
{
CScriptArgReader argStream ( luaVM );
if ( !argStream.NextIsFunction ( 1 ) && !argStream.NextIsFunction ( 2 ) )
{
// Call type 1
// bool callRemote ( string host [, int connectionAttempts = 10, int connectTimeout = 10000 ], string resourceName, string functionName, callback callbackFunction, [ arguments... ] )
SString strHost; uint uiConnectionAttempts; uint uiConnectTimeoutMs; SString strResourceName; SString strFunctionName; CLuaFunctionRef iLuaFunction; CLuaArguments args;
argStream.ReadString ( strHost );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 );
argStream.ReadString ( strResourceName );
argStream.ReadString ( strFunctionName );
argStream.ReadFunction ( iLuaFunction );
argStream.ReadLuaArguments ( args );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
g_pGame->GetRemoteCalls ()->Call ( strHost, strResourceName, strFunctionName, &args, luaMain, iLuaFunction, uiConnectionAttempts, uiConnectTimeoutMs );
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
{
// Call type 2
// bool callRemote ( string URL [, int connectionAttempts = 10, int connectTimeout = 10000 ], callback callbackFunction, [ arguments... ] )
SString strURL; uint uiConnectionAttempts; uint uiConnectTimeoutMs; CLuaFunctionRef iLuaFunction; CLuaArguments args;
argStream.ReadString ( strURL );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 );
if ( argStream.NextIsNumber () )
MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" );
argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 );
argStream.ReadFunction ( iLuaFunction );
argStream.ReadLuaArguments ( args );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( luaMain )
{
g_pGame->GetRemoteCalls ()->Call ( strURL, &args, luaMain, iLuaFunction, uiConnectionAttempts, uiConnectTimeoutMs );
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}