예제 #1
0
        protected async void HandlePovDataUpdate(object sender, PovDataUpdateEventArgs e)
        {
            Console.WriteLine("SignalR client: Received this message: {0}", e.tmp);

            Console.WriteLine("{0}", e.payload.leddata.Length);
            HubPovData hubpd = new HubPovData();

            hubpd.Init(e.payload);

            try
            {
                Console.WriteLine("SignalR client: sending UpdatePovData to Hub");

                /*await hubConn.InvokeAsync("Test",
                 *  e.tmp);*/
                await hubConn.InvokeAsync("UpdatePovData",
                                          hubpd);
            }
            catch (Exception ex)
            {
                Console.WriteLine("SignalR client: failed to send to Hub");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
예제 #2
0
        protected virtual void OnPovDataUpdate(PovDataUpdateEventArgs e)
        {
            Console.WriteLine("SocketListener: OnPovDataUpdate fired");
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            EventHandler <PovDataUpdateEventArgs> handler = PovDataUpdate;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                // Format the string to send inside the CustomEventArgs parameter
                e.tmp += $"POV data update at {DateTime.Now}";

                // Use the () operator to raise the event.
                handler(this, e);
            }
        }