ASP.NET C# SignalR - two different client roles - signalr

I am currently working on an ASP.NET MVC (with SignalR) project using C# on server side and JavaScript on client side. I want to make one client the master client who can manage the screens of the other clients, i.e. deciding which topic is to be voted for, follow the polling on his screen, be able to open and close the voting procedure etc. All the other clients do only have ONE screen, i.e. the one with the agenda point title and three voting buttons and a submit button.
The problem I encounter here is that I will then have two different clients with their own distinct screens.
What can I do using SignalR to create these two different clients, let's say an admin and councillers?
Thanks a lot !
Eric

Related

How can I communicate between a server and client in a ASP.NET webapp?

I want to make a pictionary like webapp.
I chose to develop using the .net platform, and decided to make a blazor client with a asp.net server, but I don't know how to communicate between them.
When a player is drawing something, as he/she draws, whatever he/she is drawing should appear on the other player's client, but I don't know how should to send this data to the server and back to the other clients.
I took a look at gRPC but don't know if this is the right tool for this kind of communication assuming a tickrate of 20 to 50 times a second.
You may create a Blazor WebAssembly App, which is running on the browser, and whose default means of transport is HTTP. However, you can use SignalR Client for your requirements. This is the way to go. Look up in the docs for the sample of creating a chat app in Blazor WebAssembly employing SignalR Client. There are also code samples created by the community demonstrating how to create advanced chat applications and games, and every thing involving that.
Good luck...

Website with Wcf service

I'm new to web services. i'm developing a project that includes a website for introducing information (backoffice), and that information will be send to mobile devices.
My Question is, is better to create a website that connects to the database to insert and update information and then create a webservice only for the mobile devices to get that information, or create a webservice that does all the work?(website and mobile devices connected to webservices).
Thank you
There are many solutions and which you choose depends on how your application will be used.
In any case it is always good to have reusable code, and having single service tending to both web and mobile applications would be good.
If your application is write intensive, data which is passed between user and the website is critical and data integrity must be preserved, then you should go for a single service which runs in the background, takes care of integrity and provides data retrieval and modification methods to clients (web/mobile/desktop applications).
If your application is read intensive, will be mass deployed, with tens or hundreds of thousands of clients, then you should go for each web application which connects directly to database. In this case you need to sacrifice data consistency, because writes made on one node of the web application will not be instantly visible on others. Using this method, when you need to scale out you can add replicated database nodes, and new web application nodes that connect to them.
If you have a client application running on a mobile device, you want a web service. I recommend a RESTful one using JSON. If you want to access this functionality from a computer browser, you'll want a website - which could be accessed from a browser on a mobile device.
The trade-off is accessibility vs. quality of the client application. A website may work great from a computer browser, but may not be well-suited for mobile access. The website would be a single solution though. If you use a web service, you need a mobile application to consume it (presumably for multiple platforms), plus either a desktop application to consume that web service or a website to run in a browser...
In my opinion. You should go with Services Based Architecture. You can use WCF /Asp.net Webapi on MS Stack. Using Services either SOAP Based or REST gives you more Flexibility and a degree of scalability for the consumers to consume your service.
Hope this helps.

Approach to create a web server for a game with web browser client and possibility for client software?

Basically the reason for asking this "question" is to get some information available that at least I didn't find from stackoverflow or didn't actually find by google searches.
So the product would be an multiplayer game, that would be played with browser and also be capable of being played with client software that could be programmed in C#, C++ or any other capable language. The language of the "desktop" client is coded should not be what were are discussing here about.
So the this means that we should be able to separate the presentation code, networking code and actual underlying game logic so that the server handles the game logic while clients present data from server regardless if they are the website version or the desktop client.
After all because this is a multiplayer game we have to take in account the number of connections.
The amount of connections would be more or less around 8 to 12 per "game rooms" and server could be limited to handle up to what it can handle so no problems about that either.
Here is something that I thought but I'm not sure if this is even to right direction at all.
The web interface could be coded with javascript and make use of ajax
or ajax-like technologies.
On the server-side php could be probably used and that would also
allow us to make us of sockets which will allow the client software to
connect to the server.
However can you silently update php generated pages with javascript
without having to have the actual page changing behavior?
I'm concerned about the interface flickering more or less when navigating
through different pages and I really aren't that familiar with
different "ajax technologies".
So I wish to hear and learn about different approaches to this kind of program building and I'm sure that this page could become good resource for other people struggling with this kind of issues.
Your approach is ont he correct path. The first and only webpage should serve the entire game completely in javascript. There is no concept of other 'pages' you have to navigate to. You'd do everything (browser dom manipulation, game logic, transitions, input/output, etc) in javascript code.
The game state which can be lost you'd maintain on the client, and persistent state you'd maintain on the server. You would indeed access the server through Ajax calls from within the javascript game. On the server side you would expose API's which expect some kind of parameters, and return JSON data with the results back to the javascript code.
Now on the desktop you would create the game exactly the same, except that the language you use is not javascript but for instance C# or java or C++. The gamestate you would still store on the server, and you would access it with webcalls from within the desktop game.

Need guidance on getting data to Silverlight app via ASP.NET/WCF

First of all thank you for any help. I have looked extensively and haven't found a sure solution, so here I am...
Basically I am developing an asp.net (4.0) app. One webform represents a report and is divided into two pieces:
- a div that acts like a control panel which contains textboxes, comboboxes, calendars, etc. which provide parameters for a query, and a button to get the data.
- a div that holds the silverlight control host. The silverlight app only contains a custom datagrid control.
So, as you would imagine, the user provides values for the parameters and clicks the button to get the data into the silverlight app's custom datagrid control.
-I know what you're probably asking yourself, why don't I just add the controls to the silverlight app and use RIA services. Without going into too much detail, we want a newer datagrid that we can slap into some of our existing asp.net pages.
I don't know what is the best practice for something like this. I've looked extensively and there are several options I have considered and even got my feet wet experimenting (with no success).
What I think I would like to do is have a wcf service that only sends data to the silverlight client on the page.
Let me be clear that I do not need a request/reply message exchange pattern because the silverlight client isn't going to be making any requests.
In my "quest" to accomplish this I have found examples/tutorials on duplex messaging which I think might work well if I can set the asp page as a client to the service and the silverlight app as a client to the same service.
The use clicks the button and the asp page's service reference calls the service to get the data and then in turn it sends the data to the silverlight client.
One concern I have is that all of the tutorials I have found send the messages to all of the clients, so what if two people are visiting the site at the same time? Would it update both of thier sl apps? How would I target the right client?
So my question is can anyone provide any advice, links, or other resources for a solution to this scenario?
First off, I don't think you need Silverlight. There are a ton of great UI controls out there like Telerik RadGrid that you could drop into your existing app and be up and running in an hour or two.
Having said that, if you really want to make this work, what you need is pub/sub that works both in the browser and in Silverlight. Take a look at PubNub. You get 5,000 messages per day for free, and works in virtually any client (phone, Silverlight, browser, etc) with a simple API.
Basically, your Silverlight client would subscribe to a "channel" to be notified when the filter parameters change, and your form would publish messages to this channel, either through JavaScript or server side, telling subscribers (1 in your case) of changed filter values. When the Silverlight client is notified, it would make a request for data via WCF.
Bit of a hack though. I would encourage you to drop the Silverlight and use an AJAX grid. Hope this helps!

asp.net sending data

How do you send data from an ASP.NET web application to a windows form application?? How do you establish the connection? I looked up webrequest/webresponse/post but i think thats only if you want to communicate between 2 asp.net web applications.
You might use a socket.
It would help if you're more specific about exactly what you're trying to accomplish. Do you need live communication, or would connecting to a shared database do what you need? Is the web application on the same computer as the server or a different one from the forms application?
Update:
If you're trying to pass messages to the Windows Form without using or implementing any sort of protocol, you might look into how to use LISTEN/NOTIFY on PostgreSQL. You could then just add data to a table, then have the forms application consume the data. This would have the added benefit that your forms app wouldn't have to miss any data if it was not on.
My opinion to you is to implement a webservice. I made a project for mobile devices using webservices, the mobiles had an application made in winforms that call a webmethod that made an action which was registered in the system. A web page showed the data and the events of every mobile device.
If you need an explantation of webservices you can go here.
The strategy in your case would be to implement the Observer Pattern or to raise an event to make the application or winform to be noticed about a change or action in the web page.

Resources