blob: c9c8d33be7816ae20aa131d7137388b8f52181f0 (
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
85
86
87
88
|
/* -*- C++ -*- */
//=============================================================================
/**
* @file Client_i.h
*
* Definition of the Chat Client class, Client_i.
*
* @author Pradeep Gore <pradeep@cs.wustl.edu>
*/
//=============================================================================
#ifndef CLIENT_I_H
#define CLIENT_I_H
#include "Receiver_i.h"
#include "BroadcasterC.h"
#include "ace/Read_Buffer.h"
#include "ace/Event_Handler.h"
#include "ace/SString.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/Utils/ORB_Manager.h"
#include "tao/Intrusive_Ref_Count_Handle_T.h"
/**
* @class Client_i
*
* @brief Chat Client class.
*
* Connects to the Chat server and registers the Receiver_i
* object with the chat server. It also takes in user chat
* messages and sends them to the server.
*/
class Client_i : public ACE_Event_Handler
{
public:
/// Constructor.
Client_i (void);
/// Initialize the client communication with the server.
int init (int argc, ACE_TCHAR *argv[]);
/// Start the ORB object.
int run (void);
/// Handle the user input.
virtual int handle_input (ACE_HANDLE);
private:
/// Parse the command line arguments.
/// Returns 0 on success, -1 on error.
int parse_args (int argc, ACE_TCHAR *argv[]);
/// Function to read the server ior from a file.
int read_ior (const ACE_TCHAR *filename);
/// IOR of the obj ref of the server.
ACE_CString ior_;
/// The filename that stores the ior of the server
const ACE_TCHAR* ior_file_name_;
/// Nickname of the user chatting.
ACE_CString nickname_;
/// Our orb.
TAO_ORB_Manager orb_manager_;
/// Server object ptr.
Broadcaster_var server_;
/// The receiver object.
typedef TAO_Intrusive_Ref_Count_Handle<Receiver_i> Receiver_i_var;
Receiver_i_var receiver_i_;
/// Pointer to the receiver object registered with the ORB.
Receiver_var receiver_var_;
};
#define QUIT_STRING "quit"
// The string that the user must type to quit the chat.
#endif /* CLIENT_I_H */
|