简体   繁体   中英

What is a good way to ensure that a message from a signalr Server point has been received by the client

I have a ASP.NET server app that uses SignalR. I have an HTML5 client. The server sends a small byte array (around 12k) JPEG to my client, which receives and displays the image in an IMG element.

The frequency of the data sent to the client(s) is erratic, and I am concerned about overload. At the moment I use timer control to relay messages from server at regular intervals. For desktop browsers using a dedicated broadband connection everything works smoothly, however if I use a mobile device browser the mobile can take longer to load an image for whatever reason (like poor internet connection and/or low power supply on the battery).

Ideally, I would like my client(s) to send an acknowledgement to my server to 'say' the image has been loaded OK and I am ready to receive the next one. I could facilitate the received notification either through a signal client method or say an API call.

I am worried about 2 things:

  • Unnecessary overhead from headers (etc) from client to server call

  • Negating the benefits of using SignalR

I am strongly leaning to just relying on timers in server controls and increasing the 'timeout' for mobile devices but I am open to ideas. Has anyone else encountered this type of scenario and if so have a different approach?

Try the approach documented in this answer .

Summary: Assign each JPEG an ID. When the client is ready for the next image have it report the ID of the last image loaded so that the server knows which image to send next.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM