-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
WhiteboardService.java
executable file
·146 lines (119 loc) · 5.01 KB
/
WhiteboardService.java
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.red5.service;
import java.util.Map;
import org.bigbluebutton.red5.BigBlueButtonSession;
import org.bigbluebutton.red5.Constants;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.api.Red5;
import org.slf4j.Logger;
public class WhiteboardService {
private static Logger log = Red5LoggerFactory.getLogger(WhiteboardService.class, "bigbluebutton");
private WhiteboardApplication application;
private final static String TYPE = "type";
private final static String STATUS = "status";
private final static String COR_ID = "id";
private final static String WB_ID = "whiteboardId";
public void setWhiteboardApplication(WhiteboardApplication a){
log.debug("Setting whiteboard application instance");
this.application = a;
}
private boolean validMessage(Map<String, Object> shp) {
if (shp.containsKey(COR_ID) && shp.containsKey(TYPE) &&
shp.containsKey(STATUS) && shp.containsKey(WB_ID)) return true;
return false;
}
public void sendAnnotation(Map<String, Object> annotation) {
// for (Map.Entry<String, Object> entry : annotation.entrySet()) {
// String key = entry.getKey();
// Object value = entry.getValue();
// if (key.equals("points")) {
// String points = "points=[";
// ArrayList<Double> v = (ArrayList<Double>) value;
// log.debug(points + pointsToString(v) + "]");
// } else {
// log.debug(key + "=[" + value + "]");
// }
// }
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
if (validMessage(annotation)) {
application.sendWhiteboardAnnotation(meetingID, requesterID, annotation);
}
}
/*private String pointsToString(ArrayList<Double> points){
String datapoints = "";
for (Double i : points) {
datapoints += i + ",";
}
// Trim the trailing comma
// log.debug("Data Point = " + datapoints);
return datapoints.substring(0, datapoints.length() - 1);
// application.sendShape(shape, type, color, thickness, fill, fillColor, transparency, id, status);
}*/
public void requestAnnotationHistory(Map<String, Object> message) {
log.info("WhiteboardApplication - requestAnnotationHistory");
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
String wbId = (String) message.get(WB_ID);
if (wbId != null) {
application.requestAnnotationHistory(meetingID, requesterID, wbId);
}
}
public void clear(Map<String, Object> message) {
log.info("WhiteboardApplication - Clearing board");
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
String wbId = (String) message.get(WB_ID);
if (wbId != null) {
application.clearWhiteboard(meetingID, requesterID, wbId);
}
}
public void undo(Map<String, Object> message) {
log.info("WhiteboardApplication - Deleting last graphic");
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
String wbId = (String) message.get(WB_ID);
if (wbId != null) {
application.undoWhiteboard(meetingID, requesterID, wbId);
}
}
public void toggleGrid() {
log.info("WhiteboardApplication - Toggling grid mode");
//application.toggleGrid();
}
public void modifyWhiteboardAccess(Map<String, Object> message) {
log.info("WhiteboardApplication - Setting whiteboard multi user access: " + (Boolean)message.get("multiUser"));
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
Boolean multiUser = (Boolean)message.get("multiUser");
application.modifyWhiteboardAccess(meetingID, requesterID, multiUser);
}
public void getWhiteboardAccess() {
String meetingID = getMeetingId();
String requesterID = getBbbSession().getInternalUserID();
application.getWhiteboardAccess(meetingID, requesterID);
}
private BigBlueButtonSession getBbbSession() {
return (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION);
}
private String getMeetingId(){
return Red5.getConnectionLocal().getScope().getName();
}
}