Hello all,
After looking at all the interface documentation, I am still stuck.
What I am trying to do is expose a custom interface located on the
server to be accessed by the client, like the IVEngineServer. Here is
the code I am attempting to get working (I stripped it down for
readability). This code compiles but crashes during runtime. The
overall purpose of this is to allow communication between the client and
server, but if there is a better or more correct way of doing this,
please let me know. Thanks a lot!
In src/gameshared, ITestInterface.h
#ifndef PB_ITEST_INTERFACE_H
#define PB_ITEST_INTERFACE_H
#include "cbase.h"
#define ITEST_INTERFACE_NAME "TESTINTERFACE001"
abstract_class ITestInterface
{
public:
virtual bool Message(char* msg) = 0;
};
#endif
In src/dlls, TestInterface.h
#ifndef TEST_INTERFACE_H
#define TEST_INTERFACE_H
#include "cbase.h"
#include "ITestInterface.h"
class TestInterface : public ITestInterface
{
public:
TestInterface(){};
~TestInterface(){};
//ITestInterface methods
virtual bool Message(char* msg);
};
static TestInterface* test_interface;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(TestInterface, ITestInterface,
ITEST_INTERFACE_NAME, test_interface);
bool TestInterface::Message(char* msg)
{
Msg("The message, %s, was received\n.", msg);
return true;
}
#endif
In cdll_client_int.h, I extern the interface
extern ITestInterface *test_interface;
Then from within a class in src/cdll which should simply display the
message "Yay!"
test_interface->Message("Yay!");
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders