Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hublot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoann HOUPERT
hublot
Commits
86135d8f
Commit
86135d8f
authored
Nov 07, 2017
by
Yoann HOUPERT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add webservice routes
parent
350ce343
Changes
3
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...');
loader
.
loadAll
(
'
controller
'
,
'
lib
'
,
'
robot
'
)
.
then
(
modules
=>
{
console
.
log
(
'
modules loaded... creating controller
'
);
app
.
use
(
'
/
'
,
routes
);
const
controller
=
controllerFactory
.
create
(
runner
,
modules
,
config
);
console
.
log
(
'
creating client
'
);
// Automatic way use : controller.client('test-bot');
// Note: client returned object can be used to control further the browser
// e.g.: let client = controller.client('room'); client.end();
controller
.
client
(
'
test-bot
'
);
app
.
use
(
'
/
'
,
routes
.
routesFactory
(
controller
));
app
.
listen
(
config
.
api
,
()
=>
{
console
.
log
(
'
App listening on port 3000
'
);
});
...
...
client/robot/robot.js
View file @
86135d8f
...
...
@@ -205,6 +205,8 @@ robot = {
robotController
.
disconnect
();
robot
.
clearConnection
();
robot
.
notifyEndToServer
();
return
true
;
},
// 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
)
=>
{
//controller.client(req.params.room);
res
.
status
(
200
).
json
({
message
:
'
Room Name!
'
+
req
.
params
.
room
});
});
const
controller
=
controllerFactory
;
routes
.
get
(
'
/disconnect/:room
'
,
(
req
,
res
)
=>
{
//controller.forceDisconnect(req.params.room);
res
.
status
(
200
).
json
({
message
:
'
Room Name!
'
+
req
.
params
.
room
});
});
routes
.
put
(
'
/connect/:room
'
,
(
req
,
res
)
=>
{
const
result
=
controller
.
client
(
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
)
=>
{
res
.
status
(
200
).
json
({
message
:
'
Room Test!
'
});
});
routes
.
delete
(
'
/disconnect/:room
'
,
(
req
,
res
)
=>
{
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