Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
NetAdminChat.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: NetAdminServer.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
HTTP Servlet Engine for Multiplayer Admin
13
*/
14
15
16
#include "
MemDebug.h
"
17
#include "
NetAdminChat.h
"
18
#include "
NetLobbyServer.h
"
19
#include "
NetServerConfig.h
"
20
#include "
NetUser.h
"
21
#include "
NetChat.h
"
22
#include "
NetUtil.h
"
23
24
#include "
HttpServlet.h
"
25
#include "
NetLayer.h
"
26
#include "
FormatUtil.h
"
27
28
// +-------------------------------------------------------------------+
29
30
NetAdminChat::NetAdminChat
()
31
{ }
32
33
// +-------------------------------------------------------------------+
34
35
bool
36
NetAdminChat::DoGet
(
HttpRequest
& request,
HttpResponse
& response)
37
{
38
if
(
CheckUser
(request, response)) {
39
NetLobbyServer
* lobby =
NetLobbyServer::GetInstance
();
40
41
if
(lobby) {
42
Text
msg = request.
GetParam
(
"msg"
);
43
Text
act = request.
GetParam
(
"action"
);
44
45
if
(msg.
length
()) {
46
lobby->
AddChat
(
user
, msg);
47
48
if
(
user
)
49
NetUtil::SendChat
(0xffff,
user
->
Name
(), msg);
50
}
51
52
else
if
(act.
length
()) {
53
if
(act ==
"clear"
)
54
lobby->
ClearChat
();
55
56
else
if
(act ==
"save"
)
57
lobby->
SaveChat
();
58
}
59
}
60
61
response.
SetStatus
(
HttpResponse::SC_OK
);
62
response.
AddHeader
(
"MIME-Version"
,
"1.0"
);
63
response.
AddHeader
(
"Content-Type"
,
"text/html"
);
64
response.
AddHeader
(
"Cache-Control"
,
"no-cache"
);
65
response.
AddHeader
(
"Expires"
,
"-1"
);
66
67
response.
SetContent
(
GetHead
(
"Chat"
) +
68
GetTitleBar
(
GetStatLine
(),
69
"onLoad=\"self.focus();document.chatForm.msg.focus();\""
) +
70
GetContent
() +
71
GetBodyClose
());
72
}
73
74
return
true
;
75
}
76
77
// +-------------------------------------------------------------------+
78
79
Text
80
NetAdminChat::GetContent
()
81
{
82
Text
content =
"<div style=\"overflow-y:scroll; height:240px; padding-right:4pt; padding-left:4pt; padding-bottom:4pt; padding-top:4pt; margin:4pt;\">\n"
;
83
84
int
nchat = 0;
85
NetLobbyServer
* lobby =
NetLobbyServer::GetInstance
();
86
if
(lobby) {
87
content +=
"\n<table width=\"90%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"
;
88
89
ListIter<NetChatEntry>
iter = lobby->
GetChat
();
90
while
(++iter) {
91
NetChatEntry
* c = iter.
value
();
92
93
content +=
" <tr><td nowrap width=\"130\" class=\"tiny\">"
;
94
content +=
FormatTimeString
(c->
GetTime
());
95
content +=
"</td><td nowrap width=\"80\" class=\"tiny\">"
;
96
content += c->
GetUser
();
97
content +=
"</td><td class=\"tiny\">"
;
98
content += c->
GetMessage
();
99
content +=
"</td></tr>\n"
;
100
}
101
102
content +=
"</table>\n\n"
;
103
}
104
105
content +=
"</div>\n<div class=\"content\">\n\
106
<form name=\"chatForm\" method=\"post\"action=\"/chat\">\n\
107
<table border=\"0\">\n\
108
<tr>\n\
109
<td valign=\"middle\"> <input type=\"text\" name=\"msg\" size=\"80\"></td>\n\
110
<td valign=\"middle\"> <input type=\"submit\" value=\"Send\"></td>\n\
111
</tr>\n\
112
<tr>\n\
113
<td colspan=\"2\" valign=\"middle\" class=\"std\"> <a href=\"/chat\">Refresh</a>\
114
· <a href=\"/chat?action=save\">Save</a> · <a href=\"/chat?action=clear\">Clear</a></td>\n\
115
</tr>\n\
116
</table>\n\
117
</form>\n\
118
</div>\n\n"
;
119
120
content +=
GetCopyright
();
121
return
content;
122
}
Stars45
NetAdminChat.cpp
Generated on Thu May 31 2012 16:31:12 for Starshatter_Open by
1.8.1