Example #1
0
        public void Can_enumerate_catalog()
        {
            var subject = new Subject <Device>();
            var catalog = new DeviceCatalog(subject, NullLogger <DeviceCatalog> .Instance);

            subject.OnNext(TestMessages.NewSearchResponse() with {
                Id = 7
            });
Example #2
0
        public void Catalog_can_turn_stream_of_messages_into_devices()
        {
            var subject = new Subject <Device>();
            var catalog = new DeviceCatalog(subject, NullLogger <DeviceCatalog> .Instance);

            subject.OnNext(TestMessages.NewSearchResponse());
            subject.OnNext(TestMessages.NewSearchResponse());
            var device = TestMessages.NewSearchResponse();

            subject.OnNext(device);
            subject.OnNext(device);

            catalog.Count.Should().Be(3);
        }
Example #3
0
 public DeviceParser(DeviceCatalog deviceCatalog)
 {
     this.deviceCatalog = deviceCatalog;
 }
Example #4
0
        /// <summary>
        /// 解析命令内容。
        /// </summary>
        /// <param name="aor">
        /// Address of record.
        /// eg:[email protected]
        /// </param>
        /// <param name="xml">协议命令内容。</param>
        public void Process(string aor, string xml)
        {
            CommandInfo ci = CmdIdentifier.GetCommandInfo(xml);

            switch (ci.CommandType)
            {
            case CommandType.Control:
                break;

            case CommandType.Query:
            {
                switch (ci.CommandName)
                {
                case CommandName.KeepAlive:
                    break;

                case CommandName.DeviceControl:
                    break;

                case CommandName.Catalog:
                {
                    DeviceCatalog dc = SerializeHelper.Instance.Deserialize <DeviceCatalog>(xml);
                    if (dc.DeviceID == InfoService.Instance.CurrentGateway.SipNumber)
                    {
                        Platform plat = RegisterManager.Instance.GetPlatformByAOR(aor);
                        if (plat != null)
                        {
                            ResourceSharer.Instance.ResponseToPlatform(plat);
                        }
                    }
                }
                break;

                case CommandName.DeviceStatus:
                    break;

                case CommandName.DeviceInfo:
                    break;

                case CommandName.RecordInfo:
                    break;

                case CommandName.Alarm:
                    break;

                case CommandName.Unknown:
                default:
                    break;
                }
            }
            break;

            case CommandType.Notify:
                break;

            case CommandType.Response:
                break;

            case CommandType.Unknown:
            default:
                break;
            }
        }