[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Validate parameters to Lua functions
- From: C++ RTMP Server <crtmpserver@...>
- Date: Fri, 8 Apr 2011 14:28:05 +0300
Also, if one of you guys have time and willingness to help a lua beginner with few design-pattern advices, please take a look at this 2 files:
1. This defaults all handler to default behavior written in C/C++
http://trac.rtmpd.com/browser/trunk/builders/cmake/applications/vmapp/crtmpserverdefaults.lua
2. This is where I actually overridden few functions and called the base implementation inside them besides doing some "business rules"
http://trac.rtmpd.com/browser/trunk/builders/cmake/applications/vmapp/testapp.lua
That pattern is getting me where I want to be, but I have this feeling that is not exactly "professional"
Maybe you can throw in an advice or 2
Thank you very much
Andrei
On Apr 8, 2011, at 1:16 PM, Sean Conner wrote:
> It was thus said that the Great C++ RTMP Server once stated:
>>
>> On Apr 8, 2011, at 12:11 PM, Sean Conner wrote:
>>
>>> Nope. All you can really do is see if the function exists. It's up to
>>> the function itself to check the paramters it gets.
>
>> My scenario is the other way around. I let the user define a lua callback
>> function. I know the if he defines myHandlerForMyCustomEvent function, I
>> should call it from the C++ when MyCustomEvent is triggered. Now, before
>> calling it from C/C++, what I would like is to see if, at least, has the
>> proper number of arguments (if determining the type is not possible).
>> Otherwise, the user is bound to make mistakes. If C/C++ expects
>> myHandlerForMyCustomEvent function to have 3 params and the user defines
>> that function with only 1 parameter, I would like to warn him/her before
>> continuing:
>>
>> "Hey, myHandlerForMyCustomEvent function is not defined properly for C/C++
>> needs! It will definitely not do the job because you missed 2 params"
>
> Unless you parse the submitted Lua script you can't obtain that
> information. Short of that, all you can do is trust the user to write a
> function that accepts the proper number of arguments.
>
> -spc
>
>
------
Eugen-Andrei Gavriloaie
Web: http://www.rtmpd.com