Exemplo n.º 1
0
 private IJT808Package Msg0x0704(JT808RequestInfo requestInfo, JT808Session <JT808RequestInfo> session)
 {
     return(new JT808_0x8001Package(requestInfo.JT808Package.Header, new JT808_0x8001()
     {
         MsgId = requestInfo.JT808Package.Header.MsgId,
         JT808PlatformResult = JT808PlatformResult.Success,
         MsgNum = requestInfo.JT808Package.Header.MsgNum
     }));
 }
Exemplo n.º 2
0
 private IJT808Package Msg0x0100(JT808RequestInfo requestInfo, JT808Session <JT808RequestInfo> session)
 {
     return(new JT808_0x8100Package(requestInfo.JT808Package.Header, new JT808_0x8100()
     {
         Code = "J" + requestInfo.JT808Package.Header.TerminalPhoneNo,
         JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功,
         MsgNum = requestInfo.JT808Package.Header.MsgNum
     }));
 }
Exemplo n.º 3
0
 private IJT808Package Msg0x0200(JT808RequestInfo requestInfo, JT808Session <JT808RequestInfo> session)
 {
     ((JT808Server)session.AppServer)?.ProducerFactory?.CreateProducer(JT808MsgId.位置信息汇报.ToValueString()).ProduceAsync("", requestInfo.OriginalBuffer);
     return(new JT808_0x8001Package(requestInfo.JT808Package.Header, new JT808_0x8001()
     {
         MsgId = requestInfo.JT808Package.Header.MsgId,
         JT808PlatformResult = JT808PlatformResult.Success,
         MsgNum = requestInfo.JT808Package.Header.MsgNum
     }));
 }
Exemplo n.º 4
0
        public override void ExecuteCommand(JT808Session <JT808RequestInfo> session, JT808RequestInfo requestInfo)
        {
            var JT808Server = (JT808Server)session.AppServer;

            JT808Server.SourcePackageDispatcher?.SendAsync(requestInfo.OriginalBuffer);
            if (requestInfo.JT808Package == null)
            {
                return;
            }
            JT808Server.DeviceMonitoringDispatcher?.SendAsync(requestInfo.JT808Package.Header.TerminalPhoneNo, requestInfo.OriginalBuffer);
            session.TerminalPhoneNo = requestInfo.JT808Package.Header.TerminalPhoneNo;
            string receive = requestInfo.OriginalBuffer.ToHexString();

            //session.Logger.Debug("receive-" + receive);
            //session.Logger.Debug("receive-" + requestInfo.JT808Package.Header.MsgId.ToString() + "-" + JsonConvert.SerializeObject(requestInfo.JT808Package));
            try
            {
                Func <JT808RequestInfo, JT808Session <JT808RequestInfo>, IJT808Package> handlerFunc;
                if (JT808Server.JT808MsgIdHandler.HandlerDict.TryGetValue(requestInfo.JT808Package.Header.MsgId, out handlerFunc))
                {
                    IJT808Package jT808PackageImpl = handlerFunc(requestInfo, session);
                    if (jT808PackageImpl != null)
                    {
                        session.Logger.Debug("send-" + jT808PackageImpl.JT808Package.Header.MsgId.ToString() + "-" + JT808Serializer.Serialize(jT808PackageImpl.JT808Package).ToHexString());
                        //session.Logger.Debug("send-" + jT808PackageImpl.JT808Package.Header.MsgId.ToString() + "-" + JsonConvert.SerializeObject(jT808PackageImpl.JT808Package));
                        session.TrySend(jT808PackageImpl);
                    }
                }
            }
            catch (JT808Exception ex)
            {
                session.Logger.Error("JT808Exception receive-" + receive);
                session.Logger.Error(ex.Message, ex);
            }
            catch (Exception ex)
            {
                session.Logger.Error("Exception receive-" + receive);
                session.Logger.Error(ex);
            }
        }