summaryrefslogtreecommitdiff
path: root/src/test/service.h
blob: c693ce42085c10fd773ae5c0ca0db3fccc64c52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <erebos/service.h>

namespace erebos
{

class TestService : public Service
{
public:
	using MessageWatcher = std::function<void( const Stored< Object > & )>;

	class Config
	{
	public:
		Config & onMessage( MessageWatcher );

	private:
		friend class TestService;
		vector< MessageWatcher > watchers;
	};

	TestService( Config &&, const Server & );
	virtual ~TestService();

	UUID uuid() const override;
	void handle( Context & ) override;

	static void send( const Peer &, const Ref & );

private:
	const Config config;
};

}