diff --git a/bigbluebutton-client/resources/prod/lib/bbb_deskshare.js b/bigbluebutton-client/resources/prod/lib/bbb_deskshare.js index 113f8dc9e849ac47d6ce737f7566f400ed6c271e..1212645c30a26d52be66d757f8b76dfde0fc7d1e 100644 --- a/bigbluebutton-client/resources/prod/lib/bbb_deskshare.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_deskshare.js @@ -28,7 +28,6 @@ function setScreenCoordinates(x, y) { } function stopApplet(){ - document.DeskShareApplet.destroy(); removeFrame(); } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/managers/DeskshareManager.as b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/managers/DeskshareManager.as old mode 100755 new mode 100644 index 854203609124c12472568eea36e91b498c8c83b7..b2ab3755c0dc56f9c8fa747014ad62575f6f45ef --- a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/managers/DeskshareManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/managers/DeskshareManager.as @@ -61,7 +61,12 @@ package org.bigbluebutton.modules.deskshare.managers viewWindowManager.stopViewing(); service.disconnect(); } - + + public function handleStreamStoppedEvent():void { + LogUtil.debug("Sending deskshare stopped command"); + service.stopSharingDesktop(module.getRoom(), module.getRoom()); + } + public function handleStreamStartedEvent(videoWidth:Number, videoHeight:Number):void { LogUtil.debug("Sending startViewing command"); service.sendStartViewingNotification(videoWidth, videoHeight); @@ -125,5 +130,7 @@ package org.bigbluebutton.modules.deskshare.managers LogUtil.debug("Received start vieweing command"); viewWindowManager.startViewing(module.getRoom(), videoWidth, videoHeight); } + + } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as old mode 100755 new mode 100644 index cf6a3a4df38743ea8e8d4e8d10972b225cb0fe05..fc0910b8d97879c9999f740bb8fe2d2fc9605829 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as @@ -18,8 +18,10 @@ */ package org.bigbluebutton.modules.deskshare.services { - import com.asfusion.mate.events.Dispatcher; - import flash.net.NetConnection; + import com.asfusion.mate.events.Dispatcher; + + import flash.net.NetConnection; + import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.modules.deskshare.services.red5.Connection; @@ -75,5 +77,10 @@ package org.bigbluebutton.modules.deskshare.services public function sendStartedViewingNotification(stream:String):void{ conn.sendStartedViewingNotification(stream); } + + public function stopSharingDesktop(meetingId: String, stream: String):void { + conn.stopSharingDesktop(meetingId, stream); + } + } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/red5/Connection.as b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/red5/Connection.as index e9f3a56bb384928018c5352f12c6dc0272b62f55..d01dbe39b8c71596d37a765ec21b20b76f0eefc3 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/red5/Connection.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/red5/Connection.as @@ -313,6 +313,10 @@ package org.bigbluebutton.modules.deskshare.services.red5 nc.call("deskshare.startedToViewStream", null, stream); } + public function stopSharingDesktop(meetingId: String, stream: String):void { + nc.call("deskshare.stopSharingDesktop", null, meetingId); + } + /** * Called by the server when a notification is received to start viewing the broadcast stream . * This method is called on successful execution of sendStartViewingNotification() diff --git a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/session/ISessionManagerGateway.java b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/session/ISessionManagerGateway.java old mode 100755 new mode 100644 index b28755b4c9ee0e3d1f509e223d7ab9c64b259294..25b680a3f0a8b8264bf001f3260dec27456fc92e --- a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/session/ISessionManagerGateway.java +++ b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/session/ISessionManagerGateway.java @@ -35,4 +35,6 @@ public interface ISessionManagerGateway { public void updateBlock(String room, int position, byte[] blockData, boolean keyframe, int seqNum); public void updateMouseLocation(String room, Point loc, int seqNum); + + public boolean isSharingStopped(String meetingId); } diff --git a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/socket/BlockStreamEventMessageHandler.java b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/socket/BlockStreamEventMessageHandler.java old mode 100755 new mode 100644 index 71824e322b9f8a728806266e267ba9b28a308e05..81d084e2d22837c212d192f1d3c3224b3a801813 --- a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/socket/BlockStreamEventMessageHandler.java +++ b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/socket/BlockStreamEventMessageHandler.java @@ -44,12 +44,12 @@ public class BlockStreamEventMessageHandler extends IoHandlerAdapter { } private void closeSession(IoSession session) { - String room = (String)session.getAttribute(ROOM, null); - if (room != null) { - log.info("Closing session [" + room + "]. "); - } else { - log.info("Cannot determine session to close."); - } + String room = (String)session.getAttribute(ROOM, null); + if (room != null) { + log.info("Closing session [" + room + "]. "); + } else { + log.info("Cannot determine session to close."); + } CloseFuture future = session.close(true); } @@ -64,6 +64,13 @@ public class BlockStreamEventMessageHandler extends IoHandlerAdapter { // System.out.println("Got CaptureUpdateBlockEvent"); CaptureUpdateBlockEvent event = (CaptureUpdateBlockEvent) message; sessionManager.updateBlock(event.getRoom(), event.getPosition(), event.getVideoData(), event.isKeyFrame(), event.getSequenceNum()); + if (sessionManager.isSharingStopped(event.getRoom())) { + // The flash client told us to stop sharing. Force stopping by closing connection from applet. + // We're changing how to tell the applet to stop sharing as AS ExternalInterface to JS to Applet calls + // generates a popup dialog that users may or may not see causing the browser to hang. (ralam aug 24, 2014) + log.info("Sharing has stopped for meeting [" + event.getRoom() + "]. Closing connection."); + session.close(true); + } } else if (message instanceof CaptureEndBlockEvent) { CaptureEndBlockEvent event = (CaptureEndBlockEvent) message; sessionManager.removeSession(event.getRoom(), event.getSequenceNum()); diff --git a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerGateway.scala b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerGateway.scala old mode 100755 new mode 100644 index 7f135603c178c8aee670bc1aa7491e650f064bbe..92b4b06586fced6a831a81af332178d1464dc0a4 --- a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerGateway.scala +++ b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerGateway.scala @@ -30,7 +30,7 @@ class SessionManagerGateway(streamManager: StreamManager, keyFrameInterval: Int, streamManager.start val sessionManager: SessionManagerSVC = new SessionManagerSVC(streamManager, keyFrameInterval, interframeInterval, waitForAllBlocks) - sessionManager.start + sessionManager.start def createSession(room: String, screenDim: org.bigbluebutton.deskshare.common.Dimension, blockDim: org.bigbluebutton.deskshare.common.Dimension, seqNum: Int, useSVC2: Boolean): Unit = { log.info("SessionManagerGateway:createSession for %s", room) @@ -56,4 +56,22 @@ class SessionManagerGateway(streamManager: StreamManager, keyFrameInterval: Int, log.info("SessionManagerGateway:sendKeyFrame for %s", room) sessionManager ! new SendKeyFrame(room) } + + def stopSharingDesktop(meetingId: String, stream: String) { + sessionManager ! new StopSharingDesktop(meetingId, stream) + } + + def isSharingStopped(meetingId: String): Boolean = { + var stopped = false + sessionManager !? (3000, IsSharingStopped(meetingId)) match { + case None => stopped = true + case Some(rep) => { + val reply = rep.asInstanceOf[IsSharingStoppedReply] + stopped = reply.stopped + } + } + + stopped + } + } diff --git a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerSVC.scala b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerSVC.scala old mode 100755 new mode 100644 index 9cdedda80fa2e1f3bb5623e4a7bd3f555dc3bd7a..e8d3ba7d4208c30bec7561841fd613190dbf7ee2 --- a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerSVC.scala +++ b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/sessions/SessionManagerSVC.scala @@ -21,7 +21,6 @@ package org.bigbluebutton.deskshare.server.sessions import scala.actors.Actor import scala.actors.Actor._ import net.lag.logging.Logger - import scala.collection.mutable.HashMap import org.bigbluebutton.deskshare.server.svc1.Dimension import org.bigbluebutton.deskshare.server.stream.StreamManager @@ -32,25 +31,45 @@ case class RemoveSession(room: String) case class SendKeyFrame(room: String) case class UpdateBlock(room: String, position: Int, blockData: Array[Byte], keyframe: Boolean, seqNum: Int) case class UpdateMouseLocation(room: String, mouseLoc:Point, seqNum: Int) +case class StopSharingDesktop(meetingId: String, stream: String) +case class IsSharingStopped(meetingId: String) +case class IsSharingStoppedReply(meetingId: String, stopped: Boolean) class SessionManagerSVC(streamManager: StreamManager, keyFrameInterval: Int, interframeInterval: Int, waitForAllBlocks: Boolean) extends Actor { private val log = Logger.get private val sessions = new HashMap[String, SessionSVC] - + private val stoppedSessions = new HashMap[String, String] + def act() = { loop { react { - case c: CreateSession => createSession(c); printMailbox("CreateSession") - case r: RemoveSession => removeSession(r.room); printMailbox("RemoveSession") - case k: SendKeyFrame => sendKeyFrame(k.room); printMailbox("SendKeyFrame") - case ub: UpdateBlock => updateBlock(ub.room, ub.position, ub.blockData, ub.keyframe, ub.seqNum) - case ml: UpdateMouseLocation => updateMouseLocation(ml.room, ml.mouseLoc, ml.seqNum) - case m: Any => log.warning("SessionManager: Unknown message " + m); printMailbox("Any") + case msg: CreateSession => createSession(msg); printMailbox("CreateSession") + case msg: RemoveSession => removeSession(msg.room); printMailbox("RemoveSession") + case msg: SendKeyFrame => sendKeyFrame(msg.room); printMailbox("SendKeyFrame") + case msg: UpdateBlock => updateBlock(msg.room, msg.position, msg.blockData, msg.keyframe, msg.seqNum) + case msg: UpdateMouseLocation => updateMouseLocation(msg.room, msg.mouseLoc, msg.seqNum) + case msg: StopSharingDesktop => handleStopSharingDesktop(msg) + case msg: IsSharingStopped => handleIsSharingStopped(msg) + + case msg: Any => log.warning("SessionManager: Unknown message " + msg); printMailbox("Any") } } } + private def handleStopSharingDesktop(msg: StopSharingDesktop) { + sessions.get(msg.meetingId) foreach { s => + stoppedSessions += msg.meetingId -> msg.stream + } + } + + private def handleIsSharingStopped(msg: IsSharingStopped) { + stoppedSessions.get(msg.meetingId) match { + case Some(s) => reply(new IsSharingStoppedReply(msg.meetingId, true)) + case None => reply(new IsSharingStoppedReply(msg.meetingId, false)) + } + } + private def printMailbox(caseMethod: String) { log.debug("SessionManager: mailbox %d message %s", mailboxSize, caseMethod) } @@ -84,16 +103,16 @@ class SessionManagerSVC(streamManager: StreamManager, keyFrameInterval: Int, int } } - private def removeSession(room: String): Unit = { - log.debug("SessionManager: Removing session " + room); - sessions.get(room) match { - case Some(s) => { - s ! StopSession; log.debug("++++ REMOVE SESSION +++%s", room); - val old:Int = sessions.size - sessions -= room; - log.debug("RemoveSession: Session length [%d,%d]", old, sessions.size) - } - case None => log.warning("SessionManager: Could not remove session %s. Does not exist.", room) + private def removeSession(meetingId: String): Unit = { + log.debug("SessionManager: Removing session " + meetingId); + sessions.get(meetingId) foreach { s => + s ! StopSession; log.debug("++++ REMOVE SESSION +++%s", meetingId); + val old:Int = sessions.size + sessions -= meetingId; + log.debug("RemoveSession: Session length [%d,%d]", old, sessions.size) + stoppedSessions.get(meetingId) foreach {ss => + stoppedSessions -= meetingId + } } } diff --git a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala old mode 100755 new mode 100644 index cdb749544e26fa0c7907d9b4551cf0bce2581c29..5941e86f3919bc4dc7310131b0f40d02f3dde834 --- a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala +++ b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala @@ -55,4 +55,9 @@ class DeskshareService(streamManager: StreamManager, sessionGateway: SessionMana log.debug("DeskshareService: Started viewing stream for room %s", stream) sessionGateway.sendKeyFrame(stream) } + + def stopSharingDesktop(meetingId: String) { + log.debug("DeskshareService: Stop sharing for meeting [%s]", meetingId) + sessionGateway.stopSharingDesktop(meetingId, meetingId) + } } diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/net/NetworkSocketStreamSender.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/net/NetworkSocketStreamSender.java old mode 100755 new mode 100644 index 59528ba0f32f75cc4bd4487a8d6ff8322816cd6d..5c51bb5e40afca21d77f32143b7d71a97d42f1ec --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/net/NetworkSocketStreamSender.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/net/NetworkSocketStreamSender.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Vector; - import org.bigbluebutton.deskshare.client.ExitCode; import org.bigbluebutton.deskshare.common.Dimension;