Skip to content

Commit

Permalink
multi-user whiteboard clear works
Browse files Browse the repository at this point in the history
  • Loading branch information
capilkey committed Apr 4, 2017
1 parent 1f5aff7 commit f7b9782
Show file tree
Hide file tree
Showing 29 changed files with 164 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public ClearPageWhiteboardRecordEvent() {
super();
setEvent("ClearPageEvent");
}

public void setFullClear(Boolean fullClear) {
eventMap.put("fullClear", fullClear.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object Constants {
val SHAPE = "shape"
val SHAPE_ID = "shape_id"
val MULTI_USER = "multi_user"
val FULL_CLEAR = "full_clear"
val PRESENTATION = "presentation"
val ID = "id"
val CURRENT = "current"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ case class GetCurrentPollReplyMessage(meetingID: String, recorded: Boolean, requ
// Whiteboard
case class GetWhiteboardShapesReply(meetingID: String, recorded: Boolean, requesterID: String, whiteboardId: String, shapes: Array[AnnotationVO], replyTo: String) extends IOutMessage
case class SendWhiteboardAnnotationEvent(meetingID: String, recorded: Boolean, requesterID: String, whiteboardId: String, shape: AnnotationVO) extends IOutMessage
case class ClearWhiteboardEvent(meetingID: String, recorded: Boolean, requesterID: String, whiteboardId: String) extends IOutMessage
case class ClearWhiteboardEvent(meetingID: String, recorded: Boolean, requesterID: String, whiteboardId: String, fullClear: Boolean) extends IOutMessage
case class UndoWhiteboardEvent(meetingID: String, recorded: Boolean, requesterID: String, whiteboardId: String, shapeId: String) extends IOutMessage
case class ModifiedWhiteboardAccessEvent(meetingID: String, recorded: Boolean, requesterID: String, multiUser: Boolean) extends IOutMessage
case class IsWhiteboardEnabledReply(meetingID: String, recorded: Boolean, requesterID: String, enabled: Boolean, replyTo: String) extends IOutMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,16 @@ trait WhiteboardApp {

def handleClearWhiteboardRequest(msg: ClearWhiteboardRequest) {
//println("WB: Received clear whiteboard")
// wbModel.clearWhiteboard(msg.whiteboardId)
// if (wbModel.hasWhiteboard(msg.whiteboardId)) {
// outGW.send(new ClearWhiteboardEvent(mProps.meetingID, mProps.recorded, msg.requesterID, msg.whiteboardId))
// }
wbModel.clearWhiteboard(msg.whiteboardId, msg.requesterID) foreach { fullClear =>
outGW.send(new ClearWhiteboardEvent(mProps.meetingID, mProps.recorded, msg.requesterID, msg.whiteboardId, fullClear))
}
}

def handleUndoWhiteboardRequest(msg: UndoWhiteboardRequest) {
// println("WB: Received undo whiteboard")
wbModel.undoWhiteboard(msg.whiteboardId, msg.requesterID) foreach { last =>
outGW.send(new UndoWhiteboardEvent(mProps.meetingID, mProps.recorded, msg.requesterID, msg.whiteboardId, last.id))
}
// wbModel.getWhiteboard(msg.whiteboardId) foreach { wb =>
// wbModel.undoWhiteboard(msg.whiteboardId) foreach { last =>
// outGW.send(new UndoWhiteboardEvent(mProps.meetingID, mProps.recorded, msg.requesterID, wb.id, last.id))
// }
// }
}

def handleModifyWhiteboardAccessRequest(msg: ModifyWhiteboardAccessRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,28 @@ class WhiteboardModel {
wb.shapesMap.values.flatten.toArray.sortBy(_.position);
}

/*
def clearWhiteboard(wbId: String) {
getWhiteboard(wbId) foreach { wb =>
val clearedShapes = wb.shapes.drop(wb.shapes.length)
val newWb = wb.copy(shapes = clearedShapes)
saveWhiteboard(newWb)
def clearWhiteboard(wbId: String, userId: String): Option[Boolean] = {
var cleared: Option[Boolean] = None

if (hasWhiteboard(wbId)) {
val wb = getWhiteboard(wbId)

if (_multiUser) {
if (wb.shapesMap.contains(userId)) {
val newWb = wb.copy(shapesMap = wb.shapesMap - userId)
saveWhiteboard(newWb)
cleared = Some(false)
}
} else {
if (wb.shapesMap.nonEmpty) {
val newWb = wb.copy(shapesMap = new HashMap[String, List[AnnotationVO]]())
saveWhiteboard(newWb)
cleared = Some(true)
}
}
}
cleared
}
*/

def undoWhiteboard(wbId: String, userId: String): Option[AnnotationVO] = {
var last: Option[AnnotationVO] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object WhiteboardMessageToJsonConverter {
res += "status" -> shape.status
res += "shape_type" -> shape.shapeType
res += "wb_id" -> shape.wbId
res += "user_id" -> shape.userId

val shapeMap = new scala.collection.mutable.HashMap[String, Any]()
shapeMap += "whiteboardId" -> shape.wbId
Expand Down Expand Up @@ -57,6 +58,7 @@ object WhiteboardMessageToJsonConverter {
payload.put(Constants.MEETING_ID, msg.meetingID)
payload.put(Constants.REQUESTER_ID, msg.requesterID)
payload.put(Constants.WHITEBOARD_ID, msg.whiteboardId)
payload.put(Constants.FULL_CLEAR, msg.fullClear)

val header = Util.buildHeader(MessageNames.WHITEBOARD_CLEARED, None)
Util.buildJson(header, payload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ public class ClearWhiteboardReplyMessage implements ISubscribedMessage {
public final String meetingId;
public final String whiteboardId;
public final String requesterId;
public final Boolean fullClear;


public ClearWhiteboardReplyMessage(String meetingId, String requesterId, String whiteboardId) {
public ClearWhiteboardReplyMessage(String meetingId, String requesterId, String whiteboardId, Boolean fullClear) {
this.meetingId = meetingId;
this.whiteboardId = whiteboardId;
this.requesterId = requesterId;
this.fullClear = fullClear;
}

public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingId);
payload.put(Constants.WHITEBOARD_ID, whiteboardId);
payload.put(Constants.REQUESTER_ID, requesterId);
payload.put(Constants.FULL_CLEAR, fullClear);

java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(WHITEBOARD_CLEARED_MESSAGE, VERSION, null);
return MessageBuilder.buildJson(header, payload);
Expand All @@ -44,12 +47,14 @@ public static ClearWhiteboardReplyMessage fromJson(String message) {

if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.WHITEBOARD_ID)
&& payload.has(Constants.REQUESTER_ID)) {
&& payload.has(Constants.REQUESTER_ID)
&& payload.has(Constants.FULL_CLEAR)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
Boolean fullClear = payload.get(Constants.FULL_CLEAR).getAsBoolean();

return new ClearWhiteboardReplyMessage(meetingId, requesterId, whiteboardId);
return new ClearWhiteboardReplyMessage(meetingId, requesterId, whiteboardId, fullClear);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class Constants {
public static final String SHAPES = "shapes";
public static final String SHAPE = "shape";
public static final String SHAPE_ID = "shape_id";
public static final String FULL_CLEAR = "full_clear";
public static final String PRESENTATION = "presentation";
public static final String ID = "id";
public static final String CURRENT = "current";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ public class ModifiedWhiteboardAccessMessage implements ISubscribedMessage {

public final String meetingId;
public final String requesterId;
public final Boolean multiUser;
public final Boolean multiUser;


public ModifiedWhiteboardAccessMessage(String meetingId, String requesterId, Boolean multiUser) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.multiUser = multiUser;
this.multiUser = multiUser;
}

public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingId);
payload.put(Constants.REQUESTER_ID, requesterId);
payload.put(Constants.MULTI_USER, multiUser);
payload.put(Constants.MULTI_USER, multiUser);

java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(MODIFIED_WHITEBOARD_ACCESS, VERSION, null);
return MessageBuilder.buildJson(header, payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,20 @@ public Map<String, Object> extractOuterAnnotation(JsonObject annotationElement)
if (annotationElement.has(Constants.ID)
&& annotationElement.has("shape")
&& annotationElement.has("status")
&& annotationElement.has("shape_type")){
&& annotationElement.has("shape_type")
&& annotationElement.has("user_id")){

Map<String, Object> finalAnnotation = new HashMap<String, Object>();

String id = annotationElement.get(Constants.ID).getAsString();
String status = annotationElement.get("status").getAsString();
String type = annotationElement.get("shape_type").getAsString();
String userId = annotationElement.get("user_id").getAsString();

finalAnnotation.put(Constants.ID, id);
finalAnnotation.put("type", type);
finalAnnotation.put("status", status);
finalAnnotation.put("userId", userId);

JsonElement shape = annotationElement.get("shape");
Map<String, Object> shapesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void processSendWhiteboardAnnotationReplyMessage(SendWhiteboardAnnotatio
shape.put("id", msg.shape.get("id"));
shape.put("type", msg.shape.get("type"));
shape.put("status", msg.shape.get("status"));
shape.put("userId", msg.shape.get("userId"));
shape.put("shape", msg.shape.get("shapes"));

args.put("shape", shape);
Expand Down Expand Up @@ -134,6 +135,8 @@ private void processIsWhiteboardEnabledReply(IsWhiteboardEnabledReplyMessage msg
private void processClearWhiteboardReply(ClearWhiteboardReplyMessage msg) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("whiteboardId", msg.whiteboardId);
args.put("userId", msg.requesterId);
args.put("fullClear", msg.fullClear);

Map<String, Object> message = new HashMap<String, Object>();
Gson gson = new Gson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ package org.bigbluebutton.modules.whiteboard
private function drawText(o:Annotation):void {
switch (o.status) {
case TextObject.TEXT_CREATED:
if (isPresenter)
if (o.userId == UserManager.getInstance().getConference().getMyUserId())
addPresenterText(o, true);
else
addNormalText(o);
break;
case TextObject.TEXT_UPDATED:
if (!isPresenter) {
if (o.userId != UserManager.getInstance().getConference().getMyUserId()) {
modifyText(o);
}
break;
case TextObject.TEXT_PUBLISHED:
modifyText(o);
// Inform others that we are done with listening for events and that they should re-listen for keyboard events.
if (isPresenter) {
if (o.userId == UserManager.getInstance().getConference().getMyUserId()) {
bindToKeyboardEvents(true);
wbCanvas.stage.focus = null;
currentlySelectedTextObject = null;
Expand All @@ -160,8 +160,6 @@ package org.bigbluebutton.modules.whiteboard
/* adds a new TextObject that is suited for a presenter. For example, it will be made editable and the appropriate listeners will be registered so that
the required events will be dispatched */
private function addPresenterText(o:Annotation, background:Boolean=false):void {
if (!isPresenter) return;

/**
* We will not be listening for keyboard events to input texts. Tell others to not listen for these events. For example, the presentation module
* listens for Keyboard.ENTER, Keyboard.SPACE to advance the slides. We don't want that while the presenter is typing texts.
Expand All @@ -171,6 +169,7 @@ package org.bigbluebutton.modules.whiteboard
var tobj:TextObject = shapeFactory.makeTextObject(o);
tobj.setGraphicID(o.id);
tobj.status = o.status;
tobj.userId = o.userId;
tobj.multiline = true;
tobj.wordWrap = true;

Expand Down Expand Up @@ -199,6 +198,7 @@ package org.bigbluebutton.modules.whiteboard
var tobj:TextObject = shapeFactory.makeTextObject(o);
tobj.setGraphicID(o.id);
tobj.status = o.status;
tobj.userId = o.userId;
tobj.multiline = true;
tobj.wordWrap = true;
tobj.background = false;
Expand Down Expand Up @@ -292,16 +292,28 @@ package org.bigbluebutton.modules.whiteboard
}

public function clearBoard(event:WhiteboardUpdate = null):void {
var numGraphics:int = this._annotationsList.length;
for (var i:Number = 0; i < numGraphics; i++){
removeLastGraphic();
if (event && event.userId) {
for (var i:Number = _annotationsList.length-1; i >= 0; i--){
var gobj:GraphicObject = _annotationsList[i] as GraphicObject; // TextObject not a DrawObject might have to use GraphicObject
if (gobj.userId == event.userId) {
removeGraphic(_annotationsList[i].id);
}
}
} else {
var numGraphics:int = this._annotationsList.length;
for (var j:Number = 0; j < numGraphics; j++){
removeLastGraphic();
}
}
wbCanvas.textToolbar.visible = false;
}

public function undoAnnotation(annotation:Annotation):void {
if (this._annotationsList.length > 0) {
if (annotation.type == DrawObject.TEXT) {
if (currentlySelectedTextObject && currentlySelectedTextObject.id == annotation.id) {
wbCanvas.textToolbar.visible = false;
}
removeText(annotation.id);
} else {
removeGraphic(annotation.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes

private var _id:String;
private var _type:String;

private var _status:String;
private var _userId:String;

/**
* ID we can use to match the shape in the client's view
Expand All @@ -67,10 +67,11 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
* The default constructor for the DrawObject
*
*/
public function DrawObject(id:String, type:String, status:String) {
public function DrawObject(id:String, type:String, status:String, userId:String) {
_id = id;
_type = type;
_status = status;
_userId = userId;
}

public function get id():String {
Expand All @@ -81,6 +82,10 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
return _type;
}

public function get userId():String {
return _userId;
}

public function get status():String {
return _status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class Ellipse extends DrawObject
{
public function Ellipse(id:String, type:String, status:String)
public function Ellipse(id:String, type:String, status:String, userId:String)
{
super(id, type, status);
super(id, type, status, userId);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
function get type():String;

function get id():String;

function get userId():String;

function denormalize(val:Number, side:Number):Number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes

public class Line extends DrawObject
{
public function Line(id:String, type:String, status:String)
public function Line(id:String, type:String, status:String, userId:String)
{
super(id, type, status);
super(id, type, status, userId);
}

override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number, zoom:Number):void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class Pencil extends DrawObject
{
public function Pencil(id:String, type:String, status:String)
public function Pencil(id:String, type:String, status:String, userId:String)
{
super(id, type, status);
super(id, type, status, userId);
}

override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number, zoom:Number):void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
private var _data:Array;
private var _textFields:Array;

public function PollResultObject(id:String, type:String, status:String) {
super(id, type, status)
public function PollResultObject(id:String, type:String, status:String, userId:String) {
super(id, type, status, userId)

_textFields = new Array();
data = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class Rectangle extends DrawObject
{
public function Rectangle(id:String, type:String, status:String)
public function Rectangle(id:String, type:String, status:String, userId:String)
{
super(id, type, status);
super(id, type, status, userId);
}

/**
Expand Down

0 comments on commit f7b9782

Please sign in to comment.