Skip to content

Commit 9749a80

Browse files
committed
- fix annotation history when user joins late
1 parent 44b2e55 commit 9749a80

File tree

7 files changed

+118
-113
lines changed

7 files changed

+118
-113
lines changed

bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/Presentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Presentation(String name, int numPages){
3535
for (int i = 1; i <= numPages; i++){
3636
pages.add(new Page(i));
3737
}
38-
this.activePage = pages.get(0);
38+
this.activePage = getPage(1);
3939
}
4040

4141
public String getName() {
@@ -49,7 +49,7 @@ public Page getActivePage(){
4949
public void setActivePage(int index){
5050
if ((index > pages.size()) || (index == activePage.getPageIndex())) return;
5151

52-
activePage = pages.get(index);
52+
activePage = getPage(index);
5353
}
5454

5555
public Page getPage(int pageNumber) {

bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public void sendAnnotation(Annotation annotation) {
117117
String status = annotation.getStatus();
118118

119119
if("textCreated".equals(status) || "DRAW_START".equals(status)) {
120-
// annotation.setID(Integer.toString(roomManager.getRoom(getMeetingId()).getUniqueWBGraphicIdentifier()));
121120
roomManager.getRoom(getMeetingId()).addAnnotation(annotation);
122121
} else {
123122
if ("text".equals(annotation.getType())) {

bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardRoom.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void setActivePresentation(String name) {
8080

8181
public boolean presentationExists(String name) {
8282
boolean exists = false;
83-
for (int i=0; i<presentations.size(); i++) {
83+
for (int i = 0; i < presentations.size(); i++) {
8484
if (presentations.get(i).getName().equals(name)) exists = true;
8585
}
8686
return exists;
@@ -92,14 +92,17 @@ public void addAnnotation(Annotation annotation) {
9292
}
9393

9494
public List<Annotation> getAnnotations(String presentationID, Integer pageNumber) {
95+
System.out.println("Getting annotations history for " + presentationID + " page " + pageNumber);
9596
Presentation p = getPresentation(presentationID);
9697
if (p != null) {
98+
System.out.println("Presentation " + presentationID + " found.");
9799
Page pg = p.getPage(pageNumber.intValue());
98100
if (pg != null) {
101+
System.out.println("Page found with " + pg.getAnnotations().size() + " annotations.");
99102
return pg.getAnnotations();
100103
}
101104
}
102-
105+
System.out.println("No annotations");
103106
return new ArrayList<Annotation>();
104107
}
105108

bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/WhiteboardModel.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ package org.bigbluebutton.modules.whiteboard.models
9191

9292
public function changePage(pageNum:int, numAnnotations:int):void {
9393
/* Need to increment the page by 1 as what is passed is zero-based while we store the pages as 1-based.*/
94-
var curPage:int = pageNum + 1;
94+
// var curPage:int = pageNum;
9595
// LogUtil.debug("*** Switching to page [ " + curPage + " ] ****");
96-
_currentPresentation.setCurrentPage(curPage);
96+
_currentPresentation.setCurrentPage(pageNum);
9797
_dispatcher.dispatchEvent(new WhiteboardUpdate(WhiteboardUpdate.CHANGE_PAGE));
9898
}
9999

bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ package org.bigbluebutton.modules.whiteboard.services
7878
}
7979

8080
private function handleNewAnnotationCommand(message:Object):void {
81-
// LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]");
81+
LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]");
8282
if (message.type == undefined || message.type == null || message.type == "") return;
8383
if (message.id == undefined || message.id == null || message.id == "") return;
8484
if (message.status == undefined || message.status == null || message.status == "") return;

bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/WhiteboardService.as

Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,76 @@
11
package org.bigbluebutton.modules.whiteboard.services
22
{
3-
import org.bigbluebutton.common.LogUtil;
4-
import org.bigbluebutton.core.managers.UserManager;
5-
import org.bigbluebutton.modules.present.events.PresentationEvent;
6-
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
7-
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
8-
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
9-
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
3+
import org.bigbluebutton.common.LogUtil;
4+
import org.bigbluebutton.core.managers.UserManager;
5+
import org.bigbluebutton.modules.present.events.PresentationEvent;
6+
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
7+
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
8+
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
9+
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
1010

11-
public class WhiteboardService
12-
{
13-
public var sender:MessageSender;
14-
public var receiver:MessageReceiver;
15-
public var whiteboardModel:WhiteboardModel;
16-
17-
public function getAnnotationHistory():void
18-
{
19-
var cp:Object = whiteboardModel.getCurrentPresentationAndPage();
20-
if (cp != null) {
21-
sender.requestAnnotationHistory(cp.presentationID, cp.currentPageNumber);
22-
}
23-
24-
}
25-
26-
public function modifyEnabled(e:WhiteboardPresenterEvent):void {
27-
sender.modifyEnabled(e);
28-
}
29-
30-
public function changePage(pageNum:Number):void {
31-
if (isPresenter) {
32-
// LogUtil.debug("PRESENTER Switch to page [" + pageNum + "]");
33-
sender.changePage(pageNum);
34-
} else {
35-
// LogUtil.debug("Switch to page [" + pageNum + "]");
36-
whiteboardModel.changePage(pageNum, 0);
37-
}
38-
}
39-
40-
public function toggleGrid():void {
41-
sender.toggleGrid();
42-
}
43-
11+
public class WhiteboardService
12+
{
13+
public var sender:MessageSender;
14+
public var receiver:MessageReceiver;
15+
public var whiteboardModel:WhiteboardModel;
4416

45-
public function undoGraphic():void {
46-
sender.undoGraphic()
47-
}
48-
49-
50-
public function clearBoard():void {
51-
sender.clearBoard();
52-
}
53-
54-
55-
public function sendText(e:WhiteboardDrawEvent):void {
56-
sender.sendText(e);
57-
}
58-
59-
60-
public function sendShape(e:WhiteboardDrawEvent):void {
61-
sender.sendShape(e);
62-
}
63-
64-
public function checkIsWhiteboardOn():void {
65-
sender.checkIsWhiteboardOn();
66-
}
67-
68-
public function setActivePresentation(e:PresentationEvent):void {
69-
if (isPresenter) {
17+
public function getAnnotationHistory():void
18+
{
19+
var cp:Object = whiteboardModel.getCurrentPresentationAndPage();
20+
if (cp != null) {
21+
sender.requestAnnotationHistory(cp.presentationID, cp.currentPageNumber);
22+
}
23+
}
24+
25+
public function modifyEnabled(e:WhiteboardPresenterEvent):void {
26+
sender.modifyEnabled(e);
27+
}
28+
29+
public function changePage(pageNum:Number):void {
30+
pageNum += 1;
31+
if (isPresenter) {
32+
LogUtil.debug("PRESENTER Switch to page [" + pageNum + "]");
33+
sender.changePage(pageNum);
34+
} else {
35+
LogUtil.debug("Switch to page [" + pageNum + "]");
36+
whiteboardModel.changePage(pageNum, 0);
37+
}
38+
}
39+
40+
public function toggleGrid():void {
41+
sender.toggleGrid();
42+
}
43+
44+
public function undoGraphic():void {
45+
sender.undoGraphic()
46+
}
47+
48+
public function clearBoard():void {
49+
sender.clearBoard();
50+
}
51+
52+
public function sendText(e:WhiteboardDrawEvent):void {
53+
sender.sendText(e);
54+
}
55+
56+
public function sendShape(e:WhiteboardDrawEvent):void {
57+
sender.sendShape(e);
58+
}
59+
60+
public function checkIsWhiteboardOn():void {
61+
sender.checkIsWhiteboardOn();
62+
}
63+
64+
public function setActivePresentation(e:PresentationEvent):void {
65+
if (isPresenter) {
7066
// LogUtil.debug("PRESENTER Switch to presentation [" + e.presentationName + "," + e.numberOfPages + "]");
71-
sender.setActivePresentation(e);
72-
} else {
67+
sender.setActivePresentation(e);
68+
} else {
7369
// LogUtil.debug("Switch to presentation [" + e.presentationName + "," + e.numberOfPages + "]");
74-
whiteboardModel.changePresentation(e.presentationName, e.numberOfPages);
75-
}
76-
}
77-
70+
whiteboardModel.changePresentation(e.presentationName, e.numberOfPages);
71+
}
72+
}
73+
7874
/** Helper method to test whether this user is the presenter */
7975
private function get isPresenter():Boolean {
8076
return UserManager.getInstance().getConference().amIPresenter();

bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/PencilDrawListener.as

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ package org.bigbluebutton.modules.whiteboard.views
7676
*/
7777
_isDrawing = false;
7878

79-
//check to make sure unnecessary data is not sent ex. a single click when the rectangle tool is selected
79+
// check to make sure unnecessary data is not sent ex. a single click when the rectangle tool is selected
8080
// is hardly classifiable as a rectangle, and should not be sent to the server
8181
if (tool.toolType == DrawObject.RECTANGLE ||
8282
tool.toolType == DrawObject.ELLIPSE ||
@@ -97,43 +97,50 @@ package org.bigbluebutton.modules.whiteboard.views
9797
}
9898
}
9999

100-
private function sendShapeToServer(status:String, tool:WhiteboardTool):void {
101-
if (_segment.length == 0) return;
100+
private function sendShapeToServer(status:String, tool:WhiteboardTool):void {
101+
if (_segment.length == 0) return;
102102

103-
var dobj:DrawAnnotation = _shapeFactory.createDrawObject(tool.toolType, _segment, tool.drawColor, tool.thickness, tool.fillOn, tool.fillColor, tool.transparencyOn);
103+
var dobj:DrawAnnotation = _shapeFactory.createDrawObject(tool.toolType, _segment, tool.drawColor, tool.thickness,
104+
tool.fillOn, tool.fillColor, tool.transparencyOn);
104105

105-
switch (status) {
106-
case DrawObject.DRAW_START:
107-
dobj.status = DrawObject.DRAW_START;
108-
_curID = _idGenerator.generateID();
109-
dobj.id = _curID;
110-
_drawStatus = DrawObject.DRAW_UPDATE;
111-
break;
112-
case DrawObject.DRAW_UPDATE:
113-
dobj.status = DrawObject.DRAW_UPDATE;
114-
dobj.id = _curID;
115-
break;
116-
case DrawObject.DRAW_END:
117-
dobj.status = DrawObject.DRAW_END;
118-
dobj.id = _curID;
119-
_drawStatus = DrawObject.DRAW_START;
120-
break;
121-
}
106+
/** PENCIL is a special case as each segment is a separate shape
107+
* Force the status to always DRAW_START to generate unique ids.
108+
* **/
109+
if (tool.toolType == DrawObject.PENCIL) {
110+
status = DrawObject.DRAW_START;
111+
}
112+
113+
switch (status) {
114+
case DrawObject.DRAW_START:
115+
dobj.status = DrawObject.DRAW_START;
116+
_curID = _idGenerator.generateID();
117+
dobj.id = _curID;
118+
_drawStatus = DrawObject.DRAW_UPDATE;
119+
break;
120+
case DrawObject.DRAW_UPDATE:
121+
dobj.status = DrawObject.DRAW_UPDATE;
122+
dobj.id = _curID;
123+
break;
124+
case DrawObject.DRAW_END:
125+
dobj.status = DrawObject.DRAW_END;
126+
dobj.id = _curID;
127+
_drawStatus = DrawObject.DRAW_START;
128+
break;
129+
}
122130

123-
/** PENCIL is a special case as each segment is a separate shape **/
124-
if (tool.toolType == DrawObject.PENCIL) {
125-
dobj.status = DrawObject.DRAW_START;
126-
_drawStatus = DrawObject.DRAW_START;
127-
_segment = new Array();
128-
var xy:Array = _wbCanvas.getMouseXY();
129-
_segment.push(xy[0], xy[1]);
130-
}
131+
/** PENCIL is a special case as each segment is a separate shape **/
132+
if (tool.toolType == DrawObject.PENCIL) {
133+
_drawStatus = DrawObject.DRAW_START;
134+
_segment = new Array();
135+
var xy:Array = _wbCanvas.getMouseXY();
136+
_segment.push(xy[0], xy[1]);
137+
}
131138

132-
var an:Annotation = dobj.createAnnotation(_wbModel, _ctrlKeyDown);
133-
if (an != null) {
134-
_wbCanvas.sendGraphicToServer(an, WhiteboardDrawEvent.SEND_SHAPE);
135-
}
139+
var an:Annotation = dobj.createAnnotation(_wbModel, _ctrlKeyDown);
140+
if (an != null) {
141+
_wbCanvas.sendGraphicToServer(an, WhiteboardDrawEvent.SEND_SHAPE);
142+
}
136143

137-
}
138144
}
145+
}
139146
}

0 commit comments

Comments
 (0)