function DispatchController() { } DispatchController.onCallback = function (Type, Parm) { switch (Type) { case "InitializeRsp": case "UninitializeRsp": case "LoginRsp": case "LogoutRsp": case "ServerLinkStatusNotify": case "MediaInitNotify": break; case "MonitorVideoStatusNotify": case "MonitorVideoIncomingCallNotify": DispatchController.MoniterController.onCallback(Type, Parm) break; case "VoipCallStatusNotify": case "VoipIncomingCallNotify": DispatchController.AudioCallController.onCallback(Type, Parm) DispatchController.VideoCallController.onCallback(Type, Parm) break; case "PttMonitorRsp": case "PttCallRsp": case "PttTalkRequestRsp": case "PttTalkReleaseRsp": case "PttCallStatusNotify": case "PttTalkStatusNotify": DispatchController.PttController.onCallback(Type, Parm) break; } }; DispatchController.Initialize = function () { DispatchCtrlLib.Initialize(DispatchController.onCallback) }; DispatchController.Login = function (name, password, serverIp, serverPort) { }; DispatchController.Logout = function () { }; DispatchController.StartLocation = function () { }; DispatchController.StopLocation = function () { }; DispatchController.StartSubscribeOnlineStatus = function () { }; DispatchController.StopSubscribeOnlineStatus = function () { }; DispatchController.StartSubscribeVoipStatus = function () { }; DispatchController.StopSubscribeVoipStatus = function () { }; DispatchController.SendMediaMessage = function () { }; DispatchController.WithdrawMediaMessage = function () { }; /************************** 事件 ******************************/ DispatchController.onInitializeResult = function (result, reason) { }; DispatchController.onLoginResult = function (result, reason) { }; DispatchController.onLocationNotify = function () { }; DispatchController.onOnlineStatus = function () { }; DispatchController.onVoipStatus = function () { }; DispatchController.onMediaMessage = function () { }; DispatchController.PttControllerList = new Map(); /**************************** 控件 *******************************/ /************************** 对讲控件 *****************************/ DispatchController.PttController = function () { this.onStartMoniterRsp = function (result) {}; //开始监听结果 this.onStopMoniterRsp = function (result) {}; //结束监听结果 this.onStartCallRsp = function (result) {}; //开始呼叫结果 this.onStopCallRsp = function (result) {}; //结束呼叫结果 this.onStartTalkRsp = function (result) {}; //开始讲话结果 this.onStopTalkRsp = function (result) {}; //结束讲话结果 this.onCallStatus = function (moniterStatus, callStatus) {}; //呼叫状态变更事件 this.onTalkStatus = function (status, cause, talker) {}; //话权状态变更事件 this.channelID = 0; this.moniterStatus = 0; this.callStatus = 0; } DispatchController.PttController.onCallback = function (Type, Parm) { var channelID = Parm.ChannelID; var obj = DispatchController.PttControllerList.get(channelID); if (obj) { switch (Type) { case "PttMonitorRsp": if (Parm.Type) { obj.onStartMoniterRsp(Parm.Result); //修改UI } else { obj.onStopMoniterRsp(Parm.Result); } break; case "PttCallRsp": if (Parm.Type) { obj.onStartCallRsp(Parm.Result); } else { obj.onStopCallRsp(Parm.Result); } break; case "PttTalkRequestRsp": obj.onStartTalkRsp(Parm.Result); break; case "PttTalkReleaseRsp": obj.onStopTalkRsp(Parm.Result); break; case "PttCallStatusNotify": //呼叫 obj.moniterStatus = Parm.MonitorStatus; obj.callStatus = Parm.CallStatus; obj.onCallStatus(obj.moniterStatus, obj.callStatus) break; case "PttTalkStatusNotify": //话权 obj.onTalkStatus(Parm.Type, Parm.Cause, Parm.Talker) break; } } } //打开通道 DispatchController.PttController.prototype.open = function (mode, target) { target.number; target.name; target.subscriber_id; this.channelID = DispatchCtrlLib.PttLoadChannel(); DispatchController.PttControllerList.set(this.channelID, this); //new UI -> div } //关闭通道 DispatchController.PttController.prototype.close = function () { DispatchCtrlLib.PttReleaseChannel(this.channelID); DispatchController.PttControllerList.delete(this.channelID); } //开始监听 DispatchController.PttController.prototype.startMoniter = function () { DispatchCtrlLib.startMoniter(1, this.channelID) } //结束监听 DispatchController.PttController.prototype.stopMoniter = function () { DispatchCtrlLib.startMoniter(0, this.channelID) } //开始呼叫 DispatchController.PttController.prototype.startCall = function () { DispatchCtrlLib.PttCall(this.channelID, 1); } //结束呼叫 DispatchController.PttController.prototype.stopCall = function () { DispatchCtrlLib.PttCall(this.channelID, 0); } //开始讲话 DispatchController.PttController.prototype.startTalk = function () { DispatchCtrlLib.PttTalkRequest(this.channelID); } //结束讲话 DispatchController.PttController.prototype.stopTalk = function () { DispatchCtrlLib.PttTalkRelease(this.channelID); } /************************** 语音通话控件 *****************************/ //语音通话控件 DispatchController.AudioCallController = function () { }; DispatchController.AudioCallController.onCallback = function (Type, Parm) { } //视频通话控件 DispatchController.VideoCallController = function () { }; DispatchController.VideoCallController.onCallback = function (Type, Parm) { } //视频监控控件 DispatchController.MoniterController = function () { }; DispatchController.MoniterController.onCallback = function (Type, Parm) { }