Skip to content

Commit cad792b

Browse files
author
Daniel Hochleitner
committed
renamed some basic functions to more meaningful names
1 parent a95dec5 commit cad792b

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

node/node-notify-server/server.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ if ((sslKeyPath) && (sslCertPath)) {
4747
if (srvHelper.doBasicAuth(req, res)) {
4848
// index html with overview of services
4949
if (path == '/' && fullPath.length == path.length) {
50-
srvHelper.doServeIndex(res);
50+
srvHelper.serveIndex(res);
5151
// Test client
5252
} else if (path == '/testclient') {
53-
srvHelper.doServeClient(res);
53+
srvHelper.serveClient(res);
5454
// Path notifyuser get interface
5555
} else if (path == '/notifyuser') {
56-
lItems = srvHelper.doGetNotifyInfo(req, res);
56+
lItems = srvHelper.getNotifyInfo(req, res);
5757
if (lItems) {
5858
lUserId = lItems.userid;
5959
lRoom = lItems.room;
@@ -81,7 +81,7 @@ if ((sslKeyPath) && (sslCertPath)) {
8181
});
8282
// path not found
8383
} else {
84-
srvHelper.doHttpError(404, 'Not Found', res);
84+
srvHelper.throwHttpError(404, 'Not Found', res);
8585
}
8686
}
8787
});
@@ -110,13 +110,13 @@ if ((sslKeyPath) && (sslCertPath)) {
110110
if (srvHelper.doBasicAuth(req, res)) {
111111
// index html with overview of services
112112
if (path == '/' && fullPath.length == path.length) {
113-
srvHelper.doServeIndex(res);
113+
srvHelper.serveIndex(res);
114114
// Test client
115115
} else if (path == '/testclient') {
116-
srvHelper.doServeClient(res);
116+
srvHelper.serveClient(res);
117117
// Path notifyuser get interface
118118
} else if (path == '/notifyuser') {
119-
lItems = srvHelper.doGetNotifyInfo(req, res);
119+
lItems = srvHelper.getNotifyInfo(req, res);
120120
if (lItems) {
121121
lUserId = lItems.userid;
122122
lRoom = lItems.room;
@@ -144,7 +144,7 @@ if ((sslKeyPath) && (sslCertPath)) {
144144
});
145145
// path not found
146146
} else {
147-
srvHelper.doHttpError(404, 'Not Found', res);
147+
srvHelper.throwHttpError(404, 'Not Found', res);
148148
}
149149
}
150150
});
@@ -297,4 +297,4 @@ var socketio = {
297297
// connect sockets
298298
socketio.connectSockets();
299299
// delete user session older than 3 hours
300-
srvHelper.doDeleteOldSessions();
300+
srvHelper.deleteOldSessions();

node/node-notify-server/srvhelper.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
//
1616
// HTTP Error function
1717
//
18-
doHttpError: function(errID, errMsg, res) {
18+
throwHttpError: function(errID, errMsg, res) {
1919
res.writeHead(errID, {
2020
"Content-Type": "text/plain"
2121
});
@@ -57,7 +57,7 @@ module.exports = {
5757
res.statusCode = 200;
5858
return true;
5959
} else {
60-
module.exports.doHttpError(403, 'Forbidden', res);
60+
module.exports.throwHttpError(403, 'Forbidden', res);
6161
return false;
6262
}
6363
// not enabled
@@ -69,7 +69,7 @@ module.exports = {
6969
//
7070
// Get Notify User Info from GET call
7171
//
72-
doGetNotifyInfo: function(req, res) {
72+
getNotifyInfo: function(req, res) {
7373
// parse URL
7474
var parsedUrl = url.parse(req.url, true);
7575
// get JSON
@@ -92,11 +92,11 @@ module.exports = {
9292
// check enabled sockets
9393
if (lRoom === 'private') {
9494
if (!(isPrivate)) {
95-
module.exports.doHttpError(404, 'Room private is not enabled', res);
95+
module.exports.throwHttpError(404, 'Room private is not enabled', res);
9696
}
9797
} else if (lRoom === 'public') {
9898
if (!(isPublic)) {
99-
module.exports.doHttpError(404, 'Room public is not enabled', res);
99+
module.exports.throwHttpError(404, 'Room public is not enabled', res);
100100
}
101101
}
102102
// check parameter
@@ -115,23 +115,23 @@ module.exports = {
115115
optparam: lOptParam
116116
};
117117
} else {
118-
module.exports.doHttpError(404, 'Check valid values: type', res);
118+
module.exports.throwHttpError(404, 'Check valid values: type', res);
119119
}
120120
} else {
121-
module.exports.doHttpError(404, 'Check valid values: room', res);
121+
module.exports.throwHttpError(404, 'Check valid values: room', res);
122122
}
123123
} else {
124-
module.exports.doHttpError(404, 'Check Parameter', res);
124+
module.exports.throwHttpError(404, 'Check Parameter', res);
125125
}
126126
},
127127
//
128128
// Server index.html file (Overview)
129129
//
130-
doServeIndex: function(res) {
130+
serveIndex: function(res) {
131131
fs.readFile('./index.html', function(err, html) {
132132
// HTTP 404 when error
133133
if (err) {
134-
module.exports.doHttpError(404, 'Not Found', res);
134+
module.exports.throwHttpError(404, 'Not Found', res);
135135
// write index.html
136136
} else {
137137
res.write(html);
@@ -142,11 +142,11 @@ module.exports = {
142142
//
143143
// Server client.html file (testclient)
144144
//
145-
doServeClient: function(res) {
145+
serveClient: function(res) {
146146
fs.readFile('./client.html', function(err, html) {
147147
// HTTP 404 when error
148148
if (err) {
149-
module.exports.doHttpError(404, 'Not Found', res);
149+
module.exports.throwHttpError(404, 'Not Found', res);
150150
// write index.html
151151
} else {
152152
res.write(html);
@@ -157,7 +157,7 @@ module.exports = {
157157
//
158158
// Delete user session older than 3 hours
159159
//
160-
doDeleteOldSessions: function() {
160+
deleteOldSessions: function() {
161161
setInterval(function() {
162162
localstore.deleteOldSessions(function(dbres, err) {
163163
if (dbres) {

0 commit comments

Comments
 (0)