2 * Sample code from The ACE Programmer's Guide,
3 * copyright 2003 Addison-Wesley. All Rights Reserved.
6 #ifndef __MESSAGE_RECEIVER_H_
7 #define __MESSAGE_RECEIVER_H_
9 #include "ace/Log_Msg.h"
10 #include "ace/Message_Block.h"
11 #include "ace/SOCK_Stream.h"
12 #include "ace/Svc_Handler.h"
13 #include "ace/Synch.h"
16 // Listing 1 code/ch12
17 struct DeviceCommandHeader
24 class HA_Device_Repository
27 HA_Device_Repository ();
29 int update_device (int device_id
, char *commands
);
32 ACE_Task_Base
*owner_
;
35 HA_Device_Repository::HA_Device_Repository ()
39 HA_Device_Repository::update_device (int, char *)
44 class HA_CommandHandler
: public ACE_Task
<ACE_MT_SYNCH
>
47 HA_CommandHandler (HA_Device_Repository
&rep
) : rep_(rep
)
53 HA_Device_Repository
&rep_
;
56 class Message_Receiver
:
57 public ACE_Svc_Handler
<ACE_SOCK_STREAM
, ACE_MT_SYNCH
>
60 Message_Receiver () : handler_(0)
65 Message_Receiver (HA_CommandHandler
*ch
) : handler_(ch
)
68 ACE_Message_Block
*shut_down_message ();
70 virtual int handle_input (ACE_HANDLE fd
);
72 virtual int handle_close (ACE_HANDLE
= ACE_INVALID_HANDLE
,
73 ACE_Reactor_Mask
= ACE_Event_Handler::ALL_EVENTS_MASK
)
75 this->peer ().close ();
81 int read_header (DeviceCommandHeader
*dch
);
82 int copy_payload (ACE_Message_Block
*mb
, int payload_length
);
85 HA_CommandHandler
*handler_
;
88 #endif /* __MESSAGE_RECEIVER_H */