public void Test2()
 {
     IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();
     var result1 = jT808SessionServiceDefaultImpl.GetTcpAll();
     var result2 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo("123456789001");
     var result3 = jT808SessionServiceDefaultImpl.GetTcpAll();
 }
        public void Test1()
        {
            IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();
            var result = jT808SessionServiceDefaultImpl.GetTcpAll();

            Thread.Sleep(5000);
        }
        public void GetTcpAllTest()
        {
            IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();
            var result = jT808SessionServiceDefaultImpl.GetTcpAll();
            var tons   = result.Data.Select(s => s.TerminalPhoneNo).ToList();

            foreach (var item in TNos)
            {
                Assert.Contains(item, tons);
            }
            Assert.Equal(JT808ResultCode.Ok, result.Code);
        }
        public void Test3()
        {
            // 判断通道是否关闭
            IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();
            JT808SessionManager  jT808TcpSessionManager         = ServiceProvider.GetService <JT808SessionManager>();
            var result1 = jT808SessionServiceDefaultImpl.GetTcpAll();

            SimpleTcpClient1.Down();
            Thread.Sleep(5000);
            var session = jT808TcpSessionManager.GetSessionByTerminalPhoneNo("123456789001");

            Thread.Sleep(100000);
        }
        public void RemoveByTerminalPhoneNoTest()
        {
            string tno = "123456789006";
            IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();

            SeedSession(tno);
            var result1 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo(tno);

            Assert.Equal(JT808ResultCode.Ok, result1.Code);
            Assert.True(result1.Data);
            var result2 = jT808SessionServiceDefaultImpl.GetTcpAll();

            Assert.Equal(JT808ResultCode.Ok, result2.Code);
            Assert.DoesNotContain(tno, result2.Data.Select(s => s.TerminalPhoneNo));
        }
        public void Test1()
        {
            jT808SessionServiceDefaultImpl = ServiceProvider.GetService <IJT808SessionService>();
            jT808UnificationSendService    = ServiceProvider.GetService <IJT808UnificationSendService>();
            jT808SessionServiceDefaultImpl.GetTcpAll();
            string no = "123456789001";
            // 文本信息包
            JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300
            {
                TextFlag = 5,
                TextInfo = "smallchi 518"
            });
            var data = JT808Serializer.Serialize(jT808Package2);
            JT808ResultDto <bool> jt808Result = jT808UnificationSendService.Send(no, data);

            Thread.Sleep(1000);
            Assert.Equal(200, jt808Result.Code);
            Assert.True(jt808Result.Data);
        }
예제 #7
0
        public override Task <TcpSessionInfoReply> GetTcpSessionAll(Empty request, ServerCallContext context)
        {
            var result = jT808SessionService.GetTcpAll();
            TcpSessionInfoReply reply = new TcpSessionInfoReply();

            if (result.Data != null)
            {
                foreach (var item in result.Data)
                {
                    reply.TcpSessions.Add(new SessionInfo
                    {
                        LastActiveTime  = item.LastActiveTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        StartTime       = item.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        RemoteAddressIP = item.RemoteAddressIP,
                        TerminalPhoneNo = item.TerminalPhoneNo
                    });
                }
            }
            return(Task.FromResult(reply));
        }
예제 #8
0
        /// <summary>
        /// 会话服务集合
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public JT808HttpResponse GetTcpSessionAll(JT808HttpRequest request)
        {
            var result = jT808SessionService.GetTcpAll();

            return(CreateJT808HttpResponse(result));
        }