53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include <iostream>
|
|
#include <functional>
|
|
#include <Event.h>
|
|
//#include <EventConnection.h>
|
|
//#include "bullshit.h"
|
|
#include "stack"
|
|
|
|
void ProcessMessage(const std::string& message)
|
|
{
|
|
std::cout << "Received: " << message << std::endl;
|
|
}
|
|
|
|
// TODO: BasicEvent tests here.
|
|
|
|
int main() {
|
|
BasicEvent<std::function<void(std::string)>, std::string> OnMessage;
|
|
BasicEvent<std::function<void()>> VoidDelegate;
|
|
|
|
bool run = true;
|
|
|
|
auto handler = OnMessage += [&] (const std::string& message)
|
|
{
|
|
std::cout << "GOTS A MESSAGE: " << message << std::endl;
|
|
};
|
|
auto handler2 = OnMessage += ProcessMessage;
|
|
|
|
auto handler3 = OnMessage += [&] {
|
|
std::cout << "Connect to event, with default callback, if we don't care about using the provided arguments." << std::endl;
|
|
};
|
|
|
|
while (run)
|
|
{
|
|
std::string input;
|
|
std::cin >> input;
|
|
OnMessage.Invoke(input);
|
|
VoidDelegate.Invoke();
|
|
OnMessage(input);
|
|
VoidDelegate();
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef _WIN32
|
|
extern "C" {
|
|
int wmain(int argc, wchar_t* argv[]) {
|
|
return main();
|
|
}
|
|
}
|
|
#endif
|
|
|