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
|
// $Id$
#include "Options.h"
#include "SL_Server.h"
#include "PMS_Usr.h"
#include "ace/ACE.h"
#include "ace/Log_Msg.h"
// This function "encodes" a list of friends by putting the userid's in
// a contiguous block. This block can then be transmitted over to the
// network to servers on other subnets. Several things are added to
// make decoding easier on the other end:
//
// * A count of the number of friends is prepended (assumption: there
// are no more than 9999999 friends... ;-))
// * The login userids are separated by a single space. */
int
PMS_Usr::encode (char *packet, int &packet_length)
{
if (Options::get_opt (Options::DEBUG) != 0)
ACE_DEBUG ((LM_DEBUG,
"in PMS_Usr::encode"));
char *buf_ptr = packet;
// We only send back info on friend that is actually logged in.
Protocol_Record *prp = this->get_next_friend ();
if (prp)
{
buf_ptr = this->handle_protocol_entries (ACE_OS::strecpy (buf_ptr,
prp->get_login ()),
prp->get_drwho_list ());
*buf_ptr++ = '\t';
}
*buf_ptr++ = '\n';
packet_length = buf_ptr - packet;
if (Options::get_opt (Options::DEBUG) != 0)
{
ACE_DEBUG ((LM_DEBUG,
"packet_length = %d\n",
packet_length));
ACE_OS::write (ACE_STDERR, packet, packet_length);
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
return 1;
}
// This function takes a packet received from the client and calls the
// appropriate Protocol_Manager routine to build the local table of
// friends.
int
PMS_Usr::decode (char *packet, int &packet_length)
{
if (Options::get_opt (Options::DEBUG) != 0)
{
ACE_DEBUG ((LM_DEBUG,
"in PMS_Usr::decode, packet_length = %d\n",
packet_length));
ACE_OS::write (ACE_STDERR, packet, packet_length);
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
ACE_NEW_RETURN (this->ss,
SL_Server (packet),
-1);
return 1;
}
PMS_Usr::PMS_Usr (void)
{
}
|