简体   繁体   English

asp.net mvc5 SignalR

[英]asp.net mvc5 SignalR

this question(s) is nothing really about my code. 这个问题与我的代码无关。 It's about understanding how I should do a certain thing. 关于了解我应该如何做某件事。

Question 1: 问题1:

I'm working on a fun little project that will send some info from a WPF client to a WebSite. 我正在做一个有趣的小项目,该项目将从WPF客户端向WebSite发送一些信息。 But what I want to do is, I want to be available to login onto my WPF client and send that to a user. 但是我想做的是,希望可以登录到WPF客户端并将其发送给用户。

So, let's say I login as "TestUser1" on my WPF Client I want signalR to send his Info to that user on the website. 因此,假设我在WPF客户端上以“ TestUser1”身份登录,我希望signalR将其信息发送给网站上的该用户。 So when he login to that user on the asp.net mvc5 I want him to get that information and no one else. 因此,当他登录到asp.net mvc5上的该用户时,我希望他获得该信息,而没有其他人。

Question 2: 问题2:

So if he would log in as "TestUser2" He would not get anything since it's sending the info to "TestUser1". 因此,如果他以“ TestUser2”身份登录,则不会获得任何信息,因为它将信息发送至“ TestUser1”。 Would this be possible with SiglaR? SiglaR是否有可能?

And to my other question, which is more or less a follow up. 我的另一个问题,或多或少是跟进。 As I want the WPF client to send info the website, Should I make the WPF Client the server aswell, or Should I make 1 WPF client, and than 1 WPF servers that both the website and the clients connect to. 因为我希望WPF客户端向网站发送信息,所以我应该同时将WPF客户端也配置为服务器,还是应该将1个WPF客户端以及网站和客户端都连接到1个WPF服务器。

Or would it be possible to make the Client Both the server and the Client? 还是可以使客户端既是服务器又是客户端?

The client should not be server. 客户端不应是服务器。 You need a host for your SignalR server (For example your existing Webserver). 您需要SignalR服务器的主机(例如您现有的Web服务器)。

THen use pub/sub pattern to subscribe to the username on the website and then publish on the client. 然后使用发布/订阅模式在网站上订阅用户名,然后在客户端上发布。 SignalR does not support pub/sub out of the box, either roll your own or use a library, I have created this library which I think would suit your needs perfect. SignalR不支持开箱即用的发布/订阅,无论是自己滚动还是使用库,我创建的库都可以完美满足您的需求。

https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki

Here is a little demo how you can publish and subscribe to all SignalR connection states. 这是一个小样例,您如何发布和订阅所有SignalR连接状态。

https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/tree/ConnectionStateExample/SignalR.EventAggregatorProxy.Demo.MVC4 https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/tree/ConnectionStateExample/SignalR.EventAggregatorProxy.Demo.MVC4

It broadcasts all connection states for all users to all users, but using the built in constraint API of my library it should be easy to implement 它向所有用户广播所有用户的所有连接状态,但是使用我的库的内置约束API,应该易于实现

https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki/Implement-constraint-handlers https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki/Implement-constraint-handlers

Here is a live demo: http://malmgrens.org/signalR/ 这是一个现场演示: http : //malmgrens.org/signalR/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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