summaryrefslogtreecommitdiff
path: root/examples/APG/Streams/RecordingDevice_Text.h
blob: a49f400d9223774a6330fe718906083d57e23a73 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* -*- C++ -*- */
/*
 * $Id$
 *
 * A RecordingDevice that listens to a socket and collects text.
 */

#ifndef RECORDING_DEVICE_TEXT_H
#define RECORDING_DEVICE_TEXT_H

#include "ace/FILE_IO.h"
#include "ace/FILE_Connector.h"
#include "ace/SOCK_Stream.h"
#include "ace/SOCK_Acceptor.h"

#include "CommandStream.h"
#include "MessageInfo.h"
#include "RecordingDevice.h"

class TextListenerAcceptor :
      public ACE_Event_Handler,
      public RecordingDevice
{
public:
  TextListenerAcceptor ();

  // ACE_Event_Handler interface

  int open (ACE_INET_Addr &addr);

  ACE_HANDLE get_handle (void) const;

  int handle_input (ACE_HANDLE);

  int accept (ACE_SOCK_Stream &peer);

  // RecordingDevice interface

  // Open a listening socket on the port specified by argv.
  int init (int argc, ACE_TCHAR *argv[]);

  ACE_Event_Handler *get_handler (void) const;

  virtual RecordingDevice *wait_for_activity (void);

  virtual int answer_call (void);

  virtual CallerId *retrieve_callerId (void);

  virtual int play_message (ACE_FILE_Addr &addr);

  virtual MessageType *record_message (ACE_FILE_Addr &addr);

private:
  ACE_SOCK_Acceptor acceptor_;
};

// Listing 01 code/ch18
class TextListener : public RecordingDevice
{
public:
  TextListener (TextListenerAcceptor *acceptor);

  virtual const ACE_TCHAR *get_name (void) const;

  int answer_call (void);

  CallerId *retrieve_callerId (void);

  int play_message (ACE_FILE_Addr &addr);

  MessageType *record_message (ACE_FILE_Addr &addr);

  virtual void release (void);
  // Listing 01
  // Listing 02 code/ch18
private:
  CommandStream *command_stream_;
  TextListenerAcceptor *acceptor_;
  ACE_SOCK_Stream peer_;
};
// Listing 02

#endif /* RECORDING_DEVICE_TEXT_H */