/// <summary>
        /// 设备类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private RpcResponse HandleDeviceRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;
            //调用驱动 处理业务
            DeviceProtocol deviceProtocol = masProtocol.Deserialize <DeviceProtocol>();
            string         driverCode     = GatewayMapper.GetDriverCodeByDeviceCode(deviceProtocol.DeviceCode);

            GatewayManager.DriverManager.HandleProtocolData(driverCode, masProtocol);

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
        /// <summary>
        /// 业务类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private RpcResponse HandleBusinessRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;

            //处理业务
            switch (masProtocol.ProtocolType)
            {
            case ProtocolType.UpdateCacheDataRequest:    //安全监控、人员定位缓存同步
                GatewayManager.CacheManager.HandleUpdateCacheDataRequest(masProtocol);
                break;

            //新增广播系统服务端业务请求处理  20171229
            case ProtocolType.EndPaTaskRequest:    //结束广播任务
                return(BroadCastBusinessManager.endPaTask(masProtocol));

            case ProtocolType.HangupCallRequest:    //挂断呼叫
                return(BroadCastBusinessManager.hangupCall(masProtocol));

            case ProtocolType.MakeCallRequest:    //发起呼叫
                return(BroadCastBusinessManager.makeCall(masProtocol));

            case ProtocolType.MonitorCallRequest:    //监听呼叫
                return(BroadCastBusinessManager.monitorCall(masProtocol));

            case ProtocolType.MusicControlRequest:    //音乐管理
                return(BroadCastBusinessManager.musicManage(masProtocol));

            case ProtocolType.PartitionControlRequest:    //分区管理
                return(BroadCastBusinessManager.zoneManage(masProtocol));

            case ProtocolType.PlayListControlRequest:    //播放列表管理
                return(BroadCastBusinessManager.playListManage(masProtocol));

            case ProtocolType.PlayListMusicControlRequest:    //播放列表音乐管理
                return(BroadCastBusinessManager.playListMusicManage(masProtocol));

            case ProtocolType.StartPaMusicTaskRequest:    //启动音乐广播任务
                return(BroadCastBusinessManager.startPaMusicTask(masProtocol));

            case ProtocolType.StartPaTtsTaskRequest:    //启动文字广播任务
                return(BroadCastBusinessManager.startPaTtsTask(masProtocol));

            case ProtocolType.StartPaVoiceTaskRequest:    //启动喊话广播任务
                return(BroadCastBusinessManager.startPaVoiceTask(masProtocol));

            case ProtocolType.TerminalControlRequest:    //终端管理
                return(BroadCastBusinessManager.termManage(masProtocol));

            case ProtocolType.QureyTerminalRequest:    //查询终端
                return(BroadCastBusinessManager.queryTerm(masProtocol));
            }

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
Esempio n. 3
0
        /// <summary>
        /// 设备类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private static RpcResponse HandleDeviceRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;

            //todo
            if (OnDeviceMessageArrived != null)
            {
                OnDeviceMessageArrived(masProtocol);
            }

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
Esempio n. 4
0
        /// <summary>
        /// 业务类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private static RpcResponse HandleBusinessRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;

            //todo 处理业务
            if (masProtocol.ProtocolType == ProtocolType.QueryCacheDataRequest) //网关请求获取缓存信息
            {
                QueryCacheDataResponse queryCacheDataResponse = QueryCacheDataToGateway.QueryServiceCacheDataToGateway();
                return(RpcResponse.Response <QueryCacheDataResponse>(queryCacheDataResponse));
            }

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
        /// <summary>
        /// 收到RPC消息处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private RpcResponse HandleRpcMessage(RpcRequest rpcRequest)
        {
            if (rpcRequest.RequestType == (int)RequestType.DeviceRequest)
            {
                //设备类请求,直接交给驱动处理
                return(HandleDeviceRequest(rpcRequest));
            }
            else if (rpcRequest.RequestType == (int)RequestType.BusinessRequest)
            {
                //业务类请求,网关直接处理 如心跳、获取业务数据或者交互处理 等
                return(HandleBusinessRequest(rpcRequest));
            }
            else if (rpcRequest.RequestType == (int)RequestType.DeviceUdpRequest)
            {
                /// 设备(UDP)类请求
                /// 这里是kj73n特殊的一类命令,主要用于搜索网络设备及网络参数设置
                var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;
                return(C8962UdpCommunication.HandleDeviceUdpRequest(masProtocol));
            }

            return(null);
        }