Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Fri Aug 29, 2008 5:42 am
COM Library Example |
Devs:
I've posted a demo COM object which CMud can access.
MSVC++, Studio 2003 (ATL).
http://www.nymsoft.to/comexample.zip
To try it out, create a COM variable holding the sample object:
#var tst %comcreate("examplelibrary.sampleai.1")
Then, there are three get properties to use, with arguments as follows:
responsetocompleteline(LONG channelid, BSTR completeline, BSTR* pVal)
responsetopromptline(LONG channelid, BSTR promptline, BSTR* pVal)
get_responsetopoll(LONG channelid, LONG pollinterval, BSTR* pVal)
The value returned in the last argument (and by the %comget() in CMud) is the library's response to the input.
The channel id can be used for things like a session id, or to signal out of band messages (script to script vs server to script).
Example calls doing whatever the DLL says to do would be:
#exec %comget(tst,"responsetopoll",1,1)
#exec %comget(tst,"responsetocompleteline",1,%1)
#exec %comget(tst,"responsetopromptline",1,%1)
(the latter two being somewhere like in a trigger with pattern (.*) )
The intent is that it helps to separate complete lines and prompts (lines which may be missing a cr/lf, but more importantly may indicate a pending action). The poll call is there to allow the library a chance to process things even if there hasn't been any server input for a while.
Caveats:
Come up with your own library name, class names, and GUIDs if you do anything with this to avoid colliding with other people using the demo. Be careful of threading. If you wrote the library or have examined the code, you may trust what comes out of it well enough to put it straight in an #EXEC statement. Otherwise, be careful.
-Tarn |
|