- trigger sending of rtt from server side

- send rtt of client to server so we can collect data
This commit is contained in:
Richard Alam 2017-08-16 14:05:22 -07:00
parent ec314b8105
commit 5e1297e8f8
10 changed files with 109 additions and 50 deletions

View File

@ -15,7 +15,7 @@ trait ClientToServerLatencyTracerMsgHdlr {
val envelope = BbbCoreEnvelope(ServerToClientLatencyTracerMsg.NAME, routing)
val header = BbbClientMsgHeader(ServerToClientLatencyTracerMsg.NAME, props.meetingProp.intId, msg.header.userId)
val body = ServerToClientLatencyTracerMsgBody(msg.body.timestamp, msg.body.prettyTimestamp, msg.body.tzOffset, msg.body.senderId)
val body = ServerToClientLatencyTracerMsgBody(msg.body.timestampUTC, msg.body.rtt, msg.body.senderId)
val event = ServerToClientLatencyTracerMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
outGW.send(msgEvent)

View File

@ -129,6 +129,8 @@ class MeetingActor(
var state = new MeetingState2x(None, inactivityTracker, expiryTracker)
var lastRttTestSentOn = System.currentTimeMillis()
/*******************************************************************/
//object FakeTestData extends FakeTestData
//FakeTestData.createFakeUsers(liveMeeting)
@ -357,6 +359,28 @@ class MeetingActor(
val (newState2, expireReason2) = ExpiryTrackerHelper.processMeetingExpiryAudit(outGW, eventBus, liveMeeting, state)
state = newState2
expireReason2 foreach (reason => log.info("Meeting {} expired with reason {}", props.meetingProp.intId, reason))
sendRttTraceTest()
}
def sendRttTraceTest(): Unit = {
val now = System.currentTimeMillis()
def buildDoLatencyTracerMsg(meetingId: String): BbbCommonEnvCoreMsg = {
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, "not-used")
val envelope = BbbCoreEnvelope(DoLatencyTracerMsg.NAME, routing)
val body = DoLatencyTracerMsgBody(now)
val header = BbbClientMsgHeader(DoLatencyTracerMsg.NAME, meetingId, "not-used")
val event = DoLatencyTracerMsg(header, body)
BbbCommonEnvCoreMsg(envelope, event)
}
if (now - lastRttTestSentOn > 60000) {
val event = buildDoLatencyTracerMsg(liveMeeting.props.meetingProp.intId)
outGW.send(event)
}
}
def handleExtendMeetingDuration(msg: ExtendMeetingDuration) {

View File

@ -5,12 +5,15 @@ case class AnnotationVO(id: String, status: String, annotationType: String,
object ClientToServerLatencyTracerMsg { val NAME = "ClientToServerLatencyTracerMsg" }
case class ClientToServerLatencyTracerMsg(header: BbbClientMsgHeader, body: ClientToServerLatencyTracerMsgBody) extends StandardMsg
case class ClientToServerLatencyTracerMsgBody(timestamp: Long, prettyTimestamp: String, tzOffset: Long, senderId: String)
case class ClientToServerLatencyTracerMsgBody(timestampUTC: Long, rtt: Long, senderId: String)
object ServerToClientLatencyTracerMsg { val NAME = "ServerToClientLatencyTracerMsg" }
case class ServerToClientLatencyTracerMsg(header: BbbClientMsgHeader, body: ServerToClientLatencyTracerMsgBody) extends BbbCoreMsg
case class ServerToClientLatencyTracerMsgBody(timestamp: Long, prettyTimestamp: String, tzOffset: Long, senderId: String)
case class ServerToClientLatencyTracerMsgBody(timestampUTC: Long, rtt: Long, senderId: String)
object DoLatencyTracerMsg { val NAME = "DoLatencyTracerMsg" }
case class DoLatencyTracerMsg(header: BbbClientMsgHeader, body: DoLatencyTracerMsgBody) extends BbbCoreMsg
case class DoLatencyTracerMsgBody(timestampUTC: Long)
object ClearWhiteboardEvtMsg {
val NAME = "ClearWhiteboardEvtMsg"

View File

@ -0,0 +1,14 @@
package org.bigbluebutton.core.events
{
import flash.events.Event;
public class PerformRttTraceEvent extends Event
{
public static const PERFORM_RTT_TRACE: String = "perform rtt trace event";
public function PerformRttTraceEvent()
{
super(PERFORM_RTT_TRACE, false, false);
}
}
}

View File

@ -740,7 +740,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
private function handleRoundTripLatencyReceivedEvent(event: RoundTripLatencyReceivedEvent): void {
rttLabel.text = "RTT = " + LiveMeeting.inst().whiteboardModel.latencyInSec + "s";
rttLabel.text = "RTT = " + LiveMeeting.inst().whiteboardModel.latencyInSec/1000 + "s";
}
private function handleWebRTCMediaRequestEvent(event:WebRTCMediaEvent):void {

View File

@ -26,20 +26,20 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
xmlns:mate="org.bigbluebutton.common.mate.*">
<fx:Script>
<![CDATA[
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.whiteboard.commands.GetWhiteboardAccessCommand;
import org.bigbluebutton.modules.whiteboard.commands.GetWhiteboardShapesCommand;
import org.bigbluebutton.modules.whiteboard.events.RequestNewCanvasEvent;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardAccessEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardCursorEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.managers.WhiteboardManager;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
import org.bigbluebutton.modules.whiteboard.services.MessageReceiver;
import org.bigbluebutton.modules.whiteboard.services.MessageSender;
import org.bigbluebutton.modules.whiteboard.services.WhiteboardService;
import org.bigbluebutton.core.events.PerformRttTraceEvent;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.whiteboard.commands.GetWhiteboardAccessCommand;
import org.bigbluebutton.modules.whiteboard.commands.GetWhiteboardShapesCommand;
import org.bigbluebutton.modules.whiteboard.events.RequestNewCanvasEvent;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardAccessEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardCursorEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.managers.WhiteboardManager;
import org.bigbluebutton.modules.whiteboard.services.MessageReceiver;
import org.bigbluebutton.modules.whiteboard.services.MessageSender;
import org.bigbluebutton.modules.whiteboard.services.WhiteboardService;
]]>
</fx:Script>
@ -51,6 +51,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<EventHandlers type="{GetWhiteboardAccessCommand.GET_ACCESS}" >
<MethodInvoker generator="{WhiteboardService}" method="getWhiteboardAccess"/>
</EventHandlers>
<EventHandlers type="{PerformRttTraceEvent.PERFORM_RTT_TRACE}" >
<MethodInvoker generator="{WhiteboardService}" method="handlePerformRttTraceEvent"/>
</EventHandlers>
<EventHandlers type="{PresentationEvent.PRESENTATION_LOADED}" >
<MethodInvoker generator="{WhiteboardService}" method="setActivePresentation" arguments="{event}" />

View File

@ -57,18 +57,20 @@ package org.bigbluebutton.modules.whiteboard.models
public function set lastTraceReceivedTimestamp(ts: Number): void {
var tsDate: Date = new Date(ts);
var now: Date = new Date();
_roundTripTime = (now.time - tsDate.time) / 1000;
_roundTripTime = now.time - tsDate.time;
_dispatcher.dispatchEvent(new RoundTripLatencyReceivedEvent());
}
public function get latencyInSec(): Number {
if (_lastTraceReceivedOn.time < _lastTraceSentOn.time) {
var now: Date = new Date();
return (now.time - _lastTraceSentOn.time) / 1000;
} else {
return (_lastTraceReceivedOn.time - _lastTraceSentOn.time) / 1000;
}
return _roundTripTime;
//if (_lastTraceReceivedOn.time < _lastTraceSentOn.time) {
// var now: Date = new Date();
// return (now.time - _lastTraceSentOn.time) / 1000;
//} else {
// return (_lastTraceReceivedOn.time - _lastTraceSentOn.time) / 1000;
//}
}

View File

@ -18,9 +18,12 @@
*/
package org.bigbluebutton.modules.whiteboard.services
{
import com.asfusion.mate.events.Dispatcher;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.events.PerformRttTraceEvent;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.main.model.users.IMessageListener;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
@ -29,6 +32,8 @@ package org.bigbluebutton.modules.whiteboard.services
{
private static const LOGGER:ILogger = getClassLogger(MessageReceiver);
private var _dispatcher:Dispatcher = new Dispatcher();
public function MessageReceiver() {
BBB.initConnectionManager().addMessageListener(this);
}
@ -61,6 +66,9 @@ package org.bigbluebutton.modules.whiteboard.services
case "ServerToClientLatencyTracerMsg":
handleServerToClientLatencyTracerMsg(message);
break;
case "DoLatencyTracerMsg":
handleDoLatencyTracerMsg(message);
break;
default:
// LogUtil.warn("Cannot handle message [" + messageName + "]");
}
@ -122,9 +130,13 @@ package org.bigbluebutton.modules.whiteboard.services
private function handleServerToClientLatencyTracerMsg(message:Object):void {
var userId:String = message.body.senderId as String;
var timestamp:Number = message.body.timestamp as Number;
var timestamp:Number = message.body.timestampUTC as Number;
LiveMeeting.inst().whiteboardModel.lastTraceReceivedTimestamp = timestamp;
}
private function handleDoLatencyTracerMsg(message:Object):void {
_dispatcher.dispatchEvent(new PerformRttTraceEvent());
}
}
}

View File

@ -177,36 +177,30 @@ package org.bigbluebutton.modules.whiteboard.services
JSON.stringify(message)
);
sendClientToServerLatencyTracerMsg();
}
public function sendClientToServerLatencyTracerMsg():void {
var lastTraceSentOn: Date = LiveMeeting.inst().whiteboardModel.lastTraceSentOn;
var now: Date = new Date();
if (now.time - lastTraceSentOn.time > 60000) {
var prettyDate: String = now.toString();
var ts: Number = now.time;
var tzOffset: Number = now.timezoneOffset;
LiveMeeting.inst().whiteboardModel.sentLastTrace(now);
var message:Object = {
header: {name: "ClientToServerLatencyTracerMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()},
body: {timestamp: ts, prettyTimestamp: prettyDate, tzOffset: tzOffset, senderId: UsersUtil.getMyUserID()}
};
var _nc:ConnectionManager = BBB.initConnectionManager();
_nc.sendMessage2x(
function(result:String):void { // On successful result
//LOGGER.debug(result);
},
function(status:String):void { // status - On error occurred
//LOGGER.error(status);
},
JSON.stringify(message)
);
}
var rtt: Number = LiveMeeting.inst().whiteboardModel.latencyInSec;
LiveMeeting.inst().whiteboardModel.sentLastTrace(now);
var message:Object = {
header: {name: "ClientToServerLatencyTracerMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()},
body: {timestampUTC: now.time, rtt: rtt, senderId: UsersUtil.getMyUserID()}
};
var _nc:ConnectionManager = BBB.initConnectionManager();
_nc.sendMessage2x(
function(result:String):void { // On successful result
//LOGGER.debug(result);
},
function(status:String):void { // status - On error occurred
//LOGGER.error(status);
},
JSON.stringify(message)
);
}
}
}

View File

@ -64,5 +64,9 @@ package org.bigbluebutton.modules.whiteboard.services
public function sendCursorPosition(e:WhiteboardCursorEvent):void {
sender.sendCursorPosition(e.xPercent, e.yPercent);
}
public function handlePerformRttTraceEvent():void {
sender.sendClientToServerLatencyTracerMsg();
}
}
}