summaryrefslogtreecommitdiff
path: root/TAO/tests/Simple/chat/Broadcaster_i.h
blob: 4b09a3432657b2f12689c460ebef09a2f589700f (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
// $Id$

// ===========================================================
//
// = LIBRARY
//    TAO/tests/Simple/chat
//
// = FILENAME
//    Broadcaster_i.h
//
// = DESCRIPTION
//    Defines the implementation header for the Broadcaster interface.
//
// = AUTHOR
//    Pradeep Gore <pradeep@cs.wustl.edu>
//
// ===========================================================

#if !defined (BROADCASTER_I_H)
#define BROADCASTER_I_H

#include "BroadcasterS.h"
#include "ReceiverC.h"
#include "tao/TAO.h"
#include "ace/Containers.h"
#include "ace/SString.h"

class Broadcaster_i : public POA_Broadcaster
{
  // = TITLE
  //    The implementation of the Broadcaster class which is the servant
  //    object for the chat server.

public:
  Broadcaster_i (void);
  // Constructor

  ~Broadcaster_i (void);
  // Destructor

  virtual CORBA::Long add (Receiver_ptr receiver,
                           const char * nickname, 
                           CORBA::Environment &_tao_environment);
  // saves receiver references in a list.

  virtual CORBA::Long remove (Receiver_ptr receiver, 
                              CORBA::Environment &_tao_environment);
  // removes receiver references from the list.

  virtual void say (const char * text,
		    CORBA::Environment &_tao_environment);
  // called by Broadcaster clients to send messages.

private:
  TAO_ORB_Manager orb_manager_;
  // the ORB manager.

  struct Receiver_Data
  {
    Receiver_var receiver_;
    ACE_CString nick_;
  };
  // per client info

  typedef ACE_Unbounded_Set<Receiver_Data> RECEIVER_SET;
  typedef ACE_Unbounded_Set_Iterator<Receiver_Data> RECEIVER_SET_ITERATOR;

  RECEIVER_SET receiver_set_;
  // set of registered clients.
};

#endif /* BROADCASTER_I_H */