public void TestLocalJoinMessage()
        {
            var message = new Msgs.Messages.LocalJoinMessage()
            {
                DeviceType         = DeviceType.Android,
                NativeWidth        = 600,
                NativeHeight       = 1024,
                DpiX               = 160,
                DpiY               = 160,
                DeviceCapabilities = DeviceCapabilities.SupportsAll,
                ClientVersion      = 133713371,
                OsMajorVersion     = 42,
                OsMinorVersion     = 0,
                DisplayName        = "package.name.here"
            };

            //FIXME: Version == 0 ?
            message.Header.ChannelId          = 0;
            message.Header.RequestAcknowledge = true;
            message.Header.Version            = 0;

            var packet = AssembleSessionMessage(message, 1, 31);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("local_join.bin", ResourceType.SmartGlass), packet);
        }
Exemplo n.º 2
0
        public void TestInputServerHandshake()
        {
            InputServerHandshake packet = NanoPacketFactory
                                          .ParsePacket(ResourcesProvider.GetBytes("tcp_input_server_handshake.bin", ResourceType.Nano), _context)
                                          as InputServerHandshake;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);

            Assert.Equal <NanoChannel>(NanoChannel.Input, packet.Channel);
            Assert.Equal <NanoPayloadType>(NanoPayloadType.Streamer, packet.Header.PayloadType);

            Assert.Equal <InputPayloadType>(InputPayloadType.ServerHandshake,
                                            (InputPayloadType)packet.StreamerHeader.PacketType);
            Assert.Equal <StreamerFlags>(StreamerFlags.GotSeqAndPrev | StreamerFlags.Unknown1,
                                         packet.StreamerHeader.Flags);
            Assert.Equal <uint>(1, packet.StreamerHeader.SequenceNumber);
            Assert.Equal <uint>(0, packet.StreamerHeader.PreviousSequenceNumber);

            Assert.Equal <uint>(3, packet.ProtocolVersion);
            Assert.Equal <uint>(1280, packet.DesktopWidth);
            Assert.Equal <uint>(720, packet.DesktopHeight);
            Assert.Equal <uint>(0, packet.MaxTouches);
            Assert.Equal <uint>(672208545, packet.InitialFrameId);
        }
Exemplo n.º 3
0
        public void TestVideoClientHandshake()
        {
            VideoClientHandshake packet = NanoPacketFactory
                                          .ParsePacket(ResourcesProvider.GetBytes("tcp_video_client_handshake.bin", ResourceType.Nano), _context)
                                          as VideoClientHandshake;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);

            Assert.Equal <NanoChannel>(NanoChannel.Video, packet.Channel);
            Assert.Equal <NanoPayloadType>(NanoPayloadType.Streamer, packet.Header.PayloadType);

            Assert.Equal <VideoPayloadType>(VideoPayloadType.ClientHandshake,
                                            (VideoPayloadType)packet.StreamerHeader.PacketType);
            Assert.Equal <StreamerFlags>(StreamerFlags.GotSeqAndPrev | StreamerFlags.Unknown1,
                                         packet.StreamerHeader.Flags);
            Assert.Equal <uint>(1, packet.StreamerHeader.SequenceNumber);
            Assert.Equal <uint>(0, packet.StreamerHeader.PreviousSequenceNumber);

            Assert.Equal <uint>(3715731054, packet.InitialFrameId);
            Assert.Equal <uint>(30, packet.RequestedFormat.FPS);
            Assert.Equal <uint>(1280, packet.RequestedFormat.Width);
            Assert.Equal <uint>(720, packet.RequestedFormat.Height);
            Assert.Equal <VideoCodec>(VideoCodec.H264, packet.RequestedFormat.Codec);
        }
Exemplo n.º 4
0
        public void TestAudioServerHandshake()
        {
            AudioServerHandshake packet = NanoPacketFactory
                                          .ParsePacket(ResourcesProvider.GetBytes("tcp_audio_server_handshake.bin", ResourceType.Nano), _context)
                                          as AudioServerHandshake;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);

            Assert.Equal <NanoChannel>(NanoChannel.Audio, packet.Channel);
            Assert.Equal <NanoPayloadType>(NanoPayloadType.Streamer, packet.Header.PayloadType);

            Assert.Equal <AudioPayloadType>(AudioPayloadType.ServerHandshake,
                                            (AudioPayloadType)packet.StreamerHeader.PacketType);
            Assert.Equal <StreamerFlags>(StreamerFlags.GotSeqAndPrev | StreamerFlags.Unknown1,
                                         packet.StreamerHeader.Flags);
            Assert.Equal <uint>(1, packet.StreamerHeader.SequenceNumber);
            Assert.Equal <uint>(0, packet.StreamerHeader.PreviousSequenceNumber);

            Assert.Equal <uint>(4, packet.ProtocolVersion);
            Assert.Equal <ulong>(1495315092424, packet.ReferenceTimestamp);
            Assert.Single(packet.Formats);

            Assert.Equal <uint>(2, packet.Formats[0].Channels);
            Assert.Equal <uint>(48000, packet.Formats[0].SampleRate);
            Assert.Equal <AudioCodec>(AudioCodec.AAC, packet.Formats[0].Codec);
        }
Exemplo n.º 5
0
 public static void Init()
 {
     if (_inited)
     {
         return;
     }
     LoadProviders();
     StyleSheets = new StyleSheetDefinitionCollection();
     if (ResourcesProvider != null)
     {
         var scripts = ResourcesProvider?.GetScripts();
         if (scripts != null)
         {
             foreach (var item in scripts)
             {
                 ScriptManager.ScriptResourceMapping.AddDefinition(item.Name, item.Definition);
             }
         }
         var styleSheetDefs = ResourcesProvider.GetStyleSheets();
         //throw new System.Exception($"{styleSheetDefs.Count()} StyleSheets loaded from provider");
         if (styleSheetDefs != null)
         {
             foreach (StyleSheetDefinition item in styleSheetDefs)
             {
                 WebResourceManagement.StyleSheets.Add(item);
             }
         }
     }
     _inited = true;
 }
Exemplo n.º 6
0
        async private void DeleteLinkItem()
        {
            var flag = await ResourcesProvider.DisplayAlert(
                AppResources.DeleteDialogTitle,
                AppResources.DeleteDialogQuestion,
                AppResources.DeleteDialogYesAnswer,
                AppResources.DeleteDialogNoAnswer);

            if (!flag)
            {
                return;
            }

            var linkItem = new LinkItem()
            {
                Info          = this.Info,
                Link          = this.Link,
                Name          = this.Name,
                ID            = this.Id,
                Rank          = this.Rank,
                LastUpdatedOn = this.LastUpdatedOn
            };

            await Database.DeleteItemAsync(linkItem);

            await NavigationService.NavigateToAsync <StartPageViewModel>();
        }
Exemplo n.º 7
0
        public void TestGamestreamPreviewStatus()
        {
            string json = ResourcesProvider.GetString("gamestream_preview_status.json", ResourceType.Json);
            var    msg  = DeserializeJson <GamestreamPreviewStatusMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.PreviewStatus, msg.Type);
            Assert.False(msg.IsPublicPreview);
            Assert.False(msg.IsInternalPreview);
        }
Exemplo n.º 8
0
        public void TestGamestreamStateEmptyGuid()
        {
            string json = ResourcesProvider.GetString("gamestream_state_invalid.json", ResourceType.Json);
            var    msg  = DeserializeJson <GamestreamStateBaseMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.GamestreamState, msg.Type);
            Assert.Equal <GamestreamStateMessageType>(GamestreamStateMessageType.Invalid, msg.State);
            Assert.Equal <System.Guid>(System.Guid.Empty, msg.SessionId);
        }
Exemplo n.º 9
0
 private void btnSaveAccount_Click(object sender, EventArgs e)
 {
     user          = textBox2.Text;
     passWord      = textBox3.Text;
     textBox2.Text = user;
     textBox3.Text = passWord;
     ResourcesProvider.AddOrUpdateAccount(new[] { user, passWord });
     MessageBox.Show("Save Ok!");
 }
        public void TestPresenceRequest()
        {
            var message = new Msgn.Discovery.PresenceRequestMessage()
            {
                DeviceType = DeviceType.WindowsStore
            };
            var packet = AssembleMessage(message);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("presence_request.bin", ResourceType.SmartGlass), packet);
        }
Exemplo n.º 11
0
        public void TestCryptoSetup()
        {
            byte[] cert = ResourcesProvider.GetBytes("selfsigned_cert.bin", ResourceType.Misc);
            var    x509 = CryptoExtensions.DeserializeCertificateAsn(cert);

            CryptoContext context = new CryptoContext(x509);

            Assert.NotNull(context);
            Assert.Equal <PublicKeyType>(PublicKeyType.EC_DH_P256, context.PublicKeyType);
        }
Exemplo n.º 12
0
        public void TestGamestreamStateStopped()
        {
            string json = ResourcesProvider.GetString("gamestream_state_stopped.json", ResourceType.Json);

            var msg = DeserializeJson <GamestreamStateStoppedMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.GamestreamState, msg.Type);
            Assert.Equal <GamestreamStateMessageType>(GamestreamStateMessageType.Stopped, msg.State);
            Assert.Equal <string>("14608f3c-1c4a-4f32-9da6-179ce1001e4a", msg.SessionId.ToString());
        }
Exemplo n.º 13
0
        public void TestGamestreamStateInitializing()
        {
            string json = ResourcesProvider.GetString("gamestream_state_init.json", ResourceType.Json);
            var    msg  = DeserializeJson <GamestreamStateInitializingMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.GamestreamState, msg.Type);
            Assert.Equal <GamestreamStateMessageType>(GamestreamStateMessageType.Initializing, msg.State);
            Assert.Equal <string>("14608f3c-1c4a-4f32-9da6-179ce1001e4a", msg.SessionId.ToString());
            Assert.Equal <int>(53394, msg.TcpPort);
            Assert.Equal <int>(49665, msg.UdpPort);
        }
Exemplo n.º 14
0
        public void TestGamestreamEnabled()
        {
            string json = ResourcesProvider.GetString("gamestream_enabled.json", ResourceType.Json);
            var    msg  = DeserializeJson <GamestreamEnabledMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.GamestreamEnabled, msg.Type);
            Assert.True(msg.CanBeEnabled);
            Assert.True(msg.Enabled);
            Assert.Equal <int>(6, msg.MajorProtocolVersion);
            Assert.Equal <int>(0, msg.MinorProtocolVersion);
        }
Exemplo n.º 15
0
        public void TestUdpHandshake()
        {
            UdpHandshake packet = NanoPacketFactory
                                  .ParsePacket(ResourcesProvider.GetBytes("udp_handshake.bin", ResourceType.Nano), _context)
                                  as UdpHandshake;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);
            Assert.Equal <NanoChannel>(NanoChannel.TcpBase, packet.Channel);
            Assert.Equal <ControlHandshakeType>(ControlHandshakeType.ACK, packet.Type);
        }
Exemplo n.º 16
0
        public void TestDeserializationSingle()
        {
            var json = ResourcesProvider.GetString("console.json", ResourceType.Json);
            var dev  = JsonConvert.DeserializeObject <Device>(json, Device.GetJsonSerializerSettings());

            Assert.Equal(dev.Address, _deviceManual.Address);
            Assert.Equal(dev.DeviceType, _deviceManual.DeviceType);
            Assert.Equal(dev.Name, _deviceManual.Name);
            Assert.Equal(dev.LiveId, _deviceManual.LiveId);
            Assert.Equal(dev.HardwareId, _deviceManual.HardwareId);
        }
        public void TestPowerOn()
        {
            var message = new Msgn.Power.PowerOnMessage()
            {
                LiveId = "FD00112233FFEE66"
            };

            var packet = AssembleMessage(message);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("poweron.bin", ResourceType.SmartGlass), packet);
        }
Exemplo n.º 18
0
        public void TestCertificateDeserialize()
        {
            byte[] cert      = ResourcesProvider.GetBytes("selfsigned_cert.bin", ResourceType.Misc);
            var    x509      = CryptoExtensions.DeserializeCertificateAsn(cert);
            var    publicKey = x509.GetPublicKey();

            Assert.NotNull(x509);
            Assert.Equal <int>(3, x509.Version);
            Assert.Equal <string>("CN=Rust", x509.IssuerDN.ToString());
            Assert.Equal <string>("CN=FFFFFFFFFFF", x509.SubjectDN.ToString());
            Assert.NotNull(publicKey);
        }
Exemplo n.º 19
0
        public void TestChannelClose()
        {
            ChannelClose packet = NanoPacketFactory
                                  .ParsePacket(ResourcesProvider.GetBytes("tcp_channel_close.bin", ResourceType.Nano), _context)
                                  as ChannelClose;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);
            Assert.Equal <NanoChannel>(NanoChannel.Audio, packet.Channel);
            Assert.Equal <ChannelControlType>(ChannelControlType.Close, packet.Type);
            Assert.Equal <uint>(0, packet.Flags);
        }
Exemplo n.º 20
0
        public void TestUnknownChannelParse()
        {
            // Create channel context without any registered channels
            NanoChannelContext localContext = new NanoChannelContext();

            byte[] packetData = ResourcesProvider.GetBytes("tcp_channel_open_no_flags.bin", ResourceType.Nano);
            Assert.Throws <NanoPackingException>(() =>
            {
                NanoPacketFactory
                .ParsePacket(packetData, localContext);
            });
        }
Exemplo n.º 21
0
        public void TestControlHandshake()
        {
            ControlHandshake packet = NanoPacketFactory
                                      .ParsePacket(ResourcesProvider.GetBytes("tcp_control_handshake.bin", ResourceType.Nano), _context)
                                      as ControlHandshake;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);
            Assert.Equal <NanoChannel>(NanoChannel.TcpBase, packet.Channel);
            Assert.Equal <ControlHandshakeType>(ControlHandshakeType.SYN, packet.Type);
            Assert.Equal <ushort>(40084, packet.ConnectionId);
        }
Exemplo n.º 22
0
        public void TestChannelOpenNoFlags()
        {
            ChannelOpen packet = NanoPacketFactory
                                 .ParsePacket(ResourcesProvider.GetBytes("tcp_channel_open_no_flags.bin", ResourceType.Nano), _context)
                                 as ChannelOpen;

            Assert.NotNull(packet);
            Assert.NotNull(packet.Header);
            Assert.Equal <NanoChannel>(NanoChannel.Video, packet.Channel);
            Assert.Equal <ChannelControlType>(ChannelControlType.Open, packet.Type);
            Assert.Equal <byte[]>(new byte[0], packet.Flags);
        }
        public void TestDisconnectMessage()
        {
            var message = new Msgs.Messages.DisconnectMessage()
            {
                ErrorCode = 0,
                Reason    = DisconnectReason.Unspecified
            };

            var packet = AssembleSessionMessage(message, 57, 31);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("disconnect.bin", ResourceType.SmartGlass), packet);
        }
Exemplo n.º 24
0
        public void TestGamestreamStateStarted()
        {
            string json = ResourcesProvider.GetString("gamestream_state_started.json", ResourceType.Json);
            var    msg  = DeserializeJson <GamestreamStateStartedMessage>(json);

            Assert.Equal <BroadcastMessageType>(BroadcastMessageType.GamestreamState, msg.Type);
            Assert.Equal <GamestreamStateMessageType>(GamestreamStateMessageType.Started, msg.State);
            Assert.Equal <string>("14608f3c-1c4a-4f32-9da6-179ce1001e4a", msg.SessionId.ToString());
            Assert.False(msg.IsWirelessConnection);
            Assert.Equal <int>(0, msg.WirelessChannel);
            Assert.Equal <int>(1000000000, msg.TransmitLinkSpeed);
        }
        public void TestTitleTouchMessage()
        {
            var message = new Msgs.Messages.TitleTouchMessage()
            {
            };

            message.Header.ChannelId          = 0;
            message.Header.RequestAcknowledge = false;

            var packet = AssembleSessionMessage(message, 0, 0);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("title_touch.bin", ResourceType.SmartGlass), packet);
        }
        public void TestCompassMessage()
        {
            var message = new Msgs.Messages.CompassMessage()
            {
                Timestamp     = 0,
                MagneticNorth = 0,
                TrueNorth     = 0
            };

            var packet = AssembleSessionMessage(message, 0, 0);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("compass.bin", ResourceType.SmartGlass), packet);
        }
        public void TestUnsnapMessage()
        {
            var message = new Msgs.Messages.UnsnapMessage()
            {
                Unknown = 1
            };

            message.Header.ChannelId          = 0;
            message.Header.RequestAcknowledge = false;

            var packet = AssembleSessionMessage(message, 0, 0);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("unsnap.bin", ResourceType.SmartGlass), packet);
        }
        public void TestStopChannelMessage()
        {
            var message = new Msgs.Messages.StopChannelMessage()
            {
                ChannelIdToStop = 2
            };

            message.Header.ChannelId          = 0;
            message.Header.RequestAcknowledge = false;

            var packet = AssembleSessionMessage(message, 0, 0);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("stop_channel.bin", ResourceType.SmartGlass), packet);
        }
        public void TestPowerOffMessage()
        {
            var message = new Msgs.Messages.PowerOffMessage()
            {
                LiveId = "FD00112233FFEE66"
            };

            message.Header.ChannelId          = 0;
            message.Header.RequestAcknowledge = true;

            var packet = AssembleSessionMessage(message, 1882, 2);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("power_off.bin", ResourceType.SmartGlass), packet);
        }
        public void TestJsonMessage()
        {
            var message = new Msgs.Messages.JsonMessage()
            {
                Json = "{\"msgid\":\"2ed6c0fd.2\",\"request\":\"GetConfiguration\"}"
            };

            message.Header.ChannelId          = 151;
            message.Header.RequestAcknowledge = true;

            var packet = AssembleSessionMessage(message, 11, 31);

            Assert.Equal <byte[]>(ResourcesProvider.GetBytes("json.bin", ResourceType.SmartGlass), packet);
        }