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 16:43:05 +03:00
|
|
|
m_EventType_core_start(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;
|
|
|
|
}
|
|
|
|
|
2014-09-17 18:52:59 +03:00
|
|
|
void event(const Event::Type &type, const Event::Private *p)
|
2014-09-17 02:18:03 +03:00
|
|
|
{
|
2014-09-17 18:52:59 +03:00
|
|
|
if(type == m_EventType_core_start){
|
2014-09-17 16:43:05 +03:00
|
|
|
on_start();
|
2014-09-17 02:18:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:43:05 +03:00
|
|
|
void on_start()
|
2014-09-17 02:18:03 +03:00
|
|
|
{
|
2014-09-17 15:45:45 +03:00
|
|
|
std::cout<<"test2 start(): Calling test1"<<std::endl;
|
|
|
|
|
2014-09-17 20:58:23 +03:00
|
|
|
{ // Raw
|
2014-09-17 20:15:46 +03:00
|
|
|
Event::Type type = Event::t("test1:thing");
|
|
|
|
Event event(type, up_<Event::Private>(new test1::Thing("Nakki")));
|
|
|
|
m_server->emit_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:58:23 +03:00
|
|
|
{ // Simplified raw
|
2014-09-17 20:15:46 +03:00
|
|
|
Event event("test1:thing", new test1::Thing("Kebab"));
|
|
|
|
m_server->emit_event(std::move(event));
|
|
|
|
}
|
2014-09-17 15:45:45 +03:00
|
|
|
|
2014-09-17 20:58:23 +03:00
|
|
|
{ // Even simpler
|
2014-09-17 20:15:46 +03:00
|
|
|
m_server->emit_event("test1:thing", new test1::Thing("Pitsa"));
|
|
|
|
}
|
|
|
|
|
2014-09-17 20:58:23 +03:00
|
|
|
{ // Inline wrapper
|
2014-09-17 20:15:46 +03:00
|
|
|
test1::do_thing(m_server, "Rulla");
|
|
|
|
}
|
2014-09-17 02:18:03 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
EXPORT void* createModule_test2(interface::Server *server){
|
|
|
|
return (void*)(new Module(server));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|