forked from dyninc/OpenBFDD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandProcessor.h
executable file
·54 lines (47 loc) · 1.52 KB
/
CommandProcessor.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**************************************************************
* Copyright (c) 2010-2013, Dynamic Network Services, Inc.
* Jake Montgomery ([email protected]) & Tom Daly ([email protected])
* Distributed under the FreeBSD License - see LICENSE
***************************************************************/
// Class for handling command communication with the control app.
#pragma once
#include "SockAddr.h"
class Beacon;
/**
* Interface factory. Use delete to free this.
*
* Requires UtilsInit() to have been called.
*
* @throw - May throw an exception.
*
* @return CommandProcessor* - Will not return NULL.
*/
class CommandProcessor* MakeCommandProcessor(Beacon &beacon);
/**
* This interface handles all communication between this beacon and the control
* utility. Most of the processing is done in a worker thread.
*
*/
class CommandProcessor
{
public:
virtual ~CommandProcessor() { };
/**
*
* Starts listening, and handling commands, on the given address and port. This
* will block until socket communication can be established. This should not be
* called from different threads simultaneously.
*
* @param addr [in] - The address and port on which to listen.
*
* @return bool - false if communication could not be set up.
*/
virtual bool BeginListening(const SockAddr &addr) = 0;
/**
* Halts listening and waits for the listen thread to terminate.
* Do not call simultaneously with BeginListening().
*/
virtual void StopListening() = 0;
protected:
CommandProcessor(Beacon &) { };
};