61 lines
1.1 KiB
C++
Raw Normal View History

2014-09-17 02:18:03 +03:00
#include "interface/module.h"
#include "interface/server.h"
#include "interface/event.h"
#include "test1/include/api.h"
#include <iostream>
using interface::Event;
namespace test2 {
struct Module: public interface::Module
{
interface::Server *m_server;
Event::Type m_EventType_core_start;
Module(interface::Server *server):
m_server(server),
2014-09-17 14:53:06 +03:00
m_EventType_core_start(interface::Event::t("core:start"))
2014-09-17 02:18:03 +03:00
{
std::cout<<"test2 construct"<<std::endl;
}
2014-09-17 14:53:06 +03:00
void init()
{
std::cout<<"test2 init"<<std::endl;
m_server->sub_event(this, m_EventType_core_start);
}
2014-09-17 02:18:03 +03:00
~Module()
{
std::cout<<"test2 destruct"<<std::endl;
}
void event(const interface::Event &event)
{
if(event.type == m_EventType_core_start){
start();
}
}
void start()
{
std::cout<<"test2 start(): Calling test1"<<std::endl;
// Basic way
2014-09-17 02:18:03 +03:00
interface::Event event("test1:thing");
event.p.reset(new test1::Thing("Nakki"));
2014-09-17 14:53:06 +03:00
m_server->emit_event(event);
// Simplified by inlining
test1::do_thing(m_server, "Kebab");
2014-09-17 02:18:03 +03:00
}
};
extern "C" {
EXPORT void* createModule_test2(interface::Server *server){
return (void*)(new Module(server));
}
}
}