westbrookmd / MediaDock

This is a light-weight application to control audio playback on Windows.
MIT License
3 stars 1 forks source link

SignalR support for multiple WPF applications simultaneously in different states #16

Open westbrookmd opened 2 years ago

westbrookmd commented 2 years ago

The current state of the SignalR hub does not authenticate/authorize requests. This limits the ability to have multiple WPF applications to be in different states.

musictopia2 commented 2 years ago

would you like me to create a sample with my solution where you act like there are several wpf apps in different states. my remote control already handles perfectly the following:

  1. i have a remote control that handles television shows
  2. i have another one that handles movies.

if there was a situation where a movie and a television show was being shown at the same time but by different users on the network, its a easy situation because one page is dedicated to tv shows and another one is for movies. for my solution, even if i add any other remote control stuff (not even necessarily media), then it works for as many different systems as you want. that is why my has 2 different servers. one server would never change no matter what. the other one is just the specifics needed for it.

westbrookmd commented 2 years ago

Thanks for the offer. I am not sure I want to implement two separate SignalR services to retain state. If I launched an application with two separate services required, this seems really expensive if it ever needed 20+ concurrent connections for each service.

I haven't documented my intentions for future development elsewhere , but I plan to not have this as a local/intranet software. I plan to have the Blazor Server UI hosted online with authentication. This could offer a secure way to control your computer's media playback without being on the same network.

I'm still learning the ins and outs of how SignalR/Blazor Server/network connections work so I appreciate your feedback on what has worked for you.

musictopia2 commented 2 years ago

For me personally, i still like it hosted locally. Because there has been times my internet has gone out. The only problem with being hosted on the internet is if somebody loses their internet connection and want to use the remote control, then would not work. I have actually created something that was like a remote control that used the internet. What I did once was the following:

I created a scoresheet app that has the following features:

  1. I have an offline version (that is a pwa that works completely offline that requires no internet.
  2. I have an online version that is blazor server side that when you enter scores, it communicates with a signal r service
  3. I have a signal r page which is readonly.

For the readonly its only display. So a person can enter scores on a phone even and then if the page is opened for the display, then a person can see on the display (even a television as long as it can visit the page). The signal r part I did in the way where if I added other score apps, that would not have to change. If you want, I can send you the link to the open source project. I did in .net 5 but have not redone for .net 6. The offline is azure static apps. The other 2 is a single app (but separate pages). I can even give you the links and let me know what you think. Of course, my solution, it only worked for one person to do (however, easy to deploy to another site so others can have their own network).

I do know if you do via azure, then https will not be a problem.

westbrookmd commented 2 years ago

Thanks for sharing your experience. I hope that my approach in hosting this online makes usage as easy as possible. I'm not certain it's the best approach, but it could be a rewarding learning experience.

Requiring users to forward ports or stay within a single network sounds like it has long-term advantages, but initial setup may be challenging for users with different permissions within their network (schools, shared networks, company networks). I'm still considering whether offering a local hosting option in addition to the online version is feasible/maintainable long-term.

It sounds like your approach in creating a hybrid app was really effective. I've been reading about the usage of blazor web assembly and hosting within github pages/azure static sites. This sounds like a really great tool to know how to implement PWAs for really cheap. I'm interested in taking a look at your code if you don't mind sharing your project!

musictopia2 commented 2 years ago

Here is the open source project. https://github.com/musictopia2/ScoresheetsBlazor

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fproud-glacier-0e73c321e.azurestaticapps.net%2F&data=04%7C01%7C%7Ca621d886df4a45fe47c108d9cf0f35bb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637768486492834452%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=DUlyHOTsj%2FNaGKExn7e%2BVrf4OOcY6QVA3JAzJF1mpJM%3D&reserved=0 this is the offline version

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmusictopiascoresheetonline.azurewebsites.net%2F&data=04%7C01%7C%7Ca621d886df4a45fe47c108d9cf0f35bb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637768486492844405%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=FUEaQwSENGUaxMpDCJRrL5jvDVbbS1jWHJCHCpbslks%3D&reserved=0

this is the one where you can enter scores for another display to see

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmusictopiascoresheetonline.azurewebsites.net%2FCousinsdisplay&data=04%7C01%7C%7Ca621d886df4a45fe47c108d9cf0f35bb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637768486492844405%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Bb7Aj78CsM9JYK6ovk7BYsnDl0w3X4Du2Z70blLBnkM%3D&reserved=0

this is one for example the cousins game where if a person enters scores for that game, then anybody who goes to this page would see the results.

musictopia2 commented 2 years ago

Forgot to mention that one major issue you could run across using azure web apps is only 60 minutes of processing time is allowed per day. If a person was using the remote control to watch a 2 hour movie and it would show the progress for the client, then most likely, after 2 hours or so, for even one user, the web app would stop working because the processing time was reached for the day. I would say I had bad experiences with port forwarding. I have a game package i created and one of my first versions of the game package because of firewalls would not work so i eventually hosted on azure. for that one, its no problem because most of the time is a person waiting to make a move, not sending messages to another player.

musictopia2 commented 2 years ago

if you would like to see the source code for the game package, the last public version is here https://github.com/musictopia2/GamingPackXV1

the one being currently worked on is here https://github.com/musictopia2/GamingPackXV3

for multiplayer, the link to play is here https://temporarygpxv1multiplayergames.azurewebsites.net/

The way it works for the system is it becomes easy to host the multiplayer part on multiple servers to get around the limitation (so others can host their own multiplayer servers). plus i designed it so for the multiplayer a person does not even have to use signal r. i created an interface so as long as its implemented, then it will work (even if using tcp sockets for local games). My first experience with signal r was actually with the game package. A few years ago, there was a talk where they had a simple chat c# app at a build conference. So I started with that. Then i decided to see how far i was able to take it and my first experience with signal r was the game package server. before, I was doing rest api calls which was much slower because you had to constantly send messages to see if there was anything else. At that time, I only allowed local hosting.

westbrookmd commented 2 years ago

Thanks for your help! I'll dive into those projects and use them as references as I encounter difficulties. It sounds like deployment is going to be an arduous process, but thankfully it's not in the near-future except for potentially a staging/dev area to test functionality.

Thanks again!