Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LINAGORA
L
LGS
Labs
hublot
Commits
86135d8f
Commit
86135d8f
authored
Nov 07, 2017
by
Yoann HOUPERT
Browse files
add webservice routes
parent
350ce343
Pipeline
#4915
passed with stage
in 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
18 deletions
+49
-18
app.js
app.js
+2
-5
client/robot/robot.js
client/robot/robot.js
+2
-0
lib/webserver/routes.js
lib/webserver/routes.js
+45
-13
No files found.
app.js
View file @
86135d8f
...
@@ -31,15 +31,12 @@ console.log('starting hublot...');
...
@@ -31,15 +31,12 @@ console.log('starting hublot...');
loader
.
loadAll
(
'
controller
'
,
'
lib
'
,
'
robot
'
)
loader
.
loadAll
(
'
controller
'
,
'
lib
'
,
'
robot
'
)
.
then
(
modules
=>
{
.
then
(
modules
=>
{
console
.
log
(
'
modules loaded... creating controller
'
);
console
.
log
(
'
modules loaded... creating controller
'
);
app
.
use
(
'
/
'
,
routes
);
const
controller
=
controllerFactory
.
create
(
runner
,
modules
,
config
);
const
controller
=
controllerFactory
.
create
(
runner
,
modules
,
config
);
console
.
log
(
'
creating client
'
);
console
.
log
(
'
creating client
'
);
// Automatic way use : controller.client('test-bot');
// Note: client returned object can be used to control further the browser
app
.
use
(
'
/
'
,
routes
.
routesFactory
(
controller
));
// e.g.: let client = controller.client('room'); client.end();
controller
.
client
(
'
test-bot
'
);
app
.
listen
(
config
.
api
,
()
=>
{
app
.
listen
(
config
.
api
,
()
=>
{
console
.
log
(
'
App listening on port 3000
'
);
console
.
log
(
'
App listening on port 3000
'
);
});
});
...
...
client/robot/robot.js
View file @
86135d8f
...
@@ -205,6 +205,8 @@ robot = {
...
@@ -205,6 +205,8 @@ robot = {
robotController
.
disconnect
();
robotController
.
disconnect
();
robot
.
clearConnection
();
robot
.
clearConnection
();
robot
.
notifyEndToServer
();
robot
.
notifyEndToServer
();
return
true
;
},
},
// This function will be overridden by a server callback
// This function will be overridden by a server callback
...
...
lib/webserver/routes.js
View file @
86135d8f
const
routes
=
require
(
'
express
'
).
Router
();
/*
* Copyright (c) 2017 Linagora.
*
* This file is part of Hublot
* (see https://ci.linagora.com/linagora/lgs/labs/hublot).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const
routesFactory
=
controllerFactory
=>
{
/* eslint new-cap: ["error", { "capIsNew": false }] */
const
routes
=
require
(
'
express
'
).
Router
();
routes
.
get
(
'
/connect/:room
'
,
(
req
,
res
)
=>
{
const
controller
=
controllerFactory
;
//controller.client(req.params.room);
res
.
status
(
200
).
json
({
message
:
'
Room Name!
'
+
req
.
params
.
room
});
});
routes
.
get
(
'
/disconnect/:room
'
,
(
req
,
res
)
=>
{
routes
.
put
(
'
/connect/:room
'
,
(
req
,
res
)
=>
{
//controller.forceDisconnect(req.params.room);
const
result
=
controller
.
client
(
req
.
params
.
room
);
res
.
status
(
200
).
json
({
message
:
'
Room Name!
'
+
req
.
params
.
room
});
if
(
result
)
{
});
res
.
status
(
201
).
json
({
message
:
'
Room
'
+
req
.
params
.
room
+
'
created
'
});
}
else
{
res
.
status
(
500
).
json
({
message
:
'
Unable to create Room
'
+
req
.
params
.
room
});
}
});
routes
.
get
(
'
/test/
'
,
(
req
,
res
)
=>
{
routes
.
delete
(
'
/disconnect/:room
'
,
(
req
,
res
)
=>
{
res
.
status
(
200
).
json
({
message
:
'
Room Test!
'
});
const
result
=
controller
.
forceDisconnect
(
req
.
params
.
room
);
});
if
(
result
)
{
res
.
status
(
200
).
json
({
message
:
'
Room
'
+
req
.
params
.
room
+
'
deleted
'
});
}
else
{
res
.
status
(
404
).
json
({
message
:
'
Unable to delete Room :
'
+
req
.
params
.
room
});
}
});
module
.
exports
=
routes
;
return
routes
;
};
module
.
exports
=
{
routesFactory
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment