Exemplo n.º 1
0
        public ChobbylaLocalListener(Chobbyla chobbyla, SteamClientHelper steam, ulong initialConnectLobbyID)
        {
            LastUserAction             = DateTime.Now;
            this.chobbyla              = chobbyla;
            this.steam                 = steam;
            steam.Listener             = this;
            this.initialConnectLobbyID = initialConnectLobbyID;
            serializer                 = new CommandJsonSerializer(Utils.GetAllTypesWithAttribute <ChobbyMessageAttribute>());
            tts = TextToSpeechBase.Create();
            steam.JoinFriendRequest          += SteamOnJoinFriendRequest;
            steam.OverlayActivated           += SteamOnOverlayActivated;
            steam.SteamOnline                += () => { SendSteamOnline(); };
            steam.SteamOffline               += () => { SendSteamOffline(); };
            discordController                 = new DiscordController(GlobalConst.ZeroKDiscordID, GlobalConst.SteamAppID.ToString());
            discordController.OnJoin         += DiscordOnJoinCallback;
            discordController.OnDisconnected += DiscordOnDisconnectedCallback;
            discordController.OnError        += DiscordOnErrorCallback;
            discordController.OnReady        += DiscordOnReadyCallback;
            discordController.OnRequest      += DiscordOnRequestCallback;
            discordController.OnSpectate     += DiscordOnSpectateCallback;

            timer      = new Timer((o) => OnTimerTick(), this, 500, 500);
            idleReport = new Timer((o) => SendCommand(new UserActivity()
            {
                IdleSeconds = WindowsApi.IdleTime.TotalSeconds
            }), this, 5000, 5000);
        }
Exemplo n.º 2
0
 public ChobbylaLocalListener(Chobbyla chobbyla, SteamClientHelper steam, ulong initialConnectLobbyID)
 {
     this.chobbyla              = chobbyla;
     this.steam                 = steam;
     steam.Listener             = this;
     this.initialConnectLobbyID = initialConnectLobbyID;
     serializer                 = new CommandJsonSerializer(Utils.GetAllTypesWithAttribute <ChobbyMessageAttribute>());
     tts = TextToSpeechBase.Create();
     steam.JoinFriendRequest += SteamOnJoinFriendRequest;
     steam.OverlayActivated  += SteamOnOverlayActivated;
     steam.SteamOnline       += () => { SendSteamOnline(); };
 }
Exemplo n.º 3
0
        public void SystemTextRoundTripMed()
        {
            var port = new SerialPort("COM12", 9600);

            port.Open();
            var serializer = new CommandJsonSerializer();

            serializer.UseLibrary = JsonLibrary.SystemTextJson;

            var listener = new DesktopSerialListener(port, serializer);

            Task.Run(() => listener.StartListening());

            UplinkFileCommand rxCmd = null;

            listener.CommandReceived += (l, command) =>
            {
                rxCmd = command as UplinkFileCommand;
            };

            var transport = new WorkerSerialTransport(serializer, port);

            transport.ExternalManageSerialPort = true; // prevent the transport from closing the port
            var payload = new StringBuilder();

            for (int i = 0; i < 100; i++)
            {
                payload.Append($"{i}: abcdefghijklmnopqrstuvwxyz\r\n");
            }

            var txCmd = new UplinkFileCommand
            {
                Destination = "arbitrary path",
                FileData    = payload.ToString()
            };

            Thread.Sleep(1000);
            transport.DeliverCommand(txCmd);
            Thread.Sleep(5000);
            Assert.NotNull(rxCmd);
            Assert.Equal(txCmd.Destination, rxCmd.Destination);
            Assert.Equal(txCmd.FileData, rxCmd.FileData);
        }
Exemplo n.º 4
0
        public Worker(F7Micro device)
        {
            // TODO: make this all configurable
            m_resultsStore = new ResultsStore();
            Registry       = Provider = new WorkerRegistry("/meadow0/test", device);

            Console.WriteLine(" Creating serial port...");
            var port = device.CreateSerialPort(
                device.SerialPortNames.Com4,
                9600,
                8,
                Parity.None,
                StopBits.One);

            Serializer = new CommandJsonSerializer(JsonLibrary.SystemTextJson);

            Listener = new MeadowSerialListener(port, Serializer);
            Listener.CommandReceived += Listener_CommandReceived;
        }
Exemplo n.º 5
0
        public void SystemTextRoundTripSmall()
        {
            var port = new SerialPort("COM12", 9600);

            port.Open();
            var serializer = new CommandJsonSerializer();

            serializer.UseLibrary = JsonLibrary.SystemTextJson;

            var listener = new DesktopSerialListener(port, serializer);

            Task.Run(() => listener.StartListening());

            UplinkFileCommand rxCmd = null;

            listener.CommandReceived += (l, command) =>
            {
                rxCmd = command as UplinkFileCommand;
            };

            var transport = new WorkerSerialTransport(serializer, port);

            transport.ExternalManageSerialPort = true; // prevent the transport from closing the port
            var txCmd = new UplinkFileCommand
            {
                Destination = "arbitrary path",
                FileData    = "foo-bar-baz"
            };

            Thread.Sleep(1000);
            transport.DeliverCommand(txCmd);
            Thread.Sleep(2000);
            Assert.NotNull(rxCmd);
            Assert.Equal(txCmd.Destination, rxCmd.Destination);
            Assert.Equal(txCmd.FileData, rxCmd.FileData);
        }