与SignalR同步调用客户端方法(Invoke client side method synchronously with SignalR)
Web服务器如何使用SignalR同步调用客户端上的方法? 这里的关键部分是服务器应该等待客户端在继续之前将数据发送回服务器?
基本上我正在寻求像WCF服务请求一样处理客户端方法调用。 调用客户端并等待返回数据。
How can the web server invoke a method on the client synchronously using SignalR? The key part here is that the server should wait for client to send data back to the server before continuing on?
Basically I'm looking to treat a client method invoke like a WCF service request. Invoke the client and wait for the data to be returned.
原文:https://stackoverflow.com/questions/14199923
更新时间:2022-03-16 11:03
最满意答案
我认为这有点棘手。 将此方法添加到
BlogRssFeed
def get_feed(self, obj, request): self.custom_var = request return super().get_feed(obj, request)
然后
ServiceStatisticsAdd(self.custom_var).add('rss', rss_reference, kwargs)
I think it is a bit tricky. Add this method to
BlogRssFeed
def get_feed(self, obj, request): self.custom_var = request return super().get_feed(obj, request)
Then
ServiceStatisticsAdd(self.custom_var).add('rss', rss_reference, kwargs)
相关问答
更多-
AutoFields由数据库本身设置,因此在保存之前不要获取值。 但是你还没有保存,因为你将commit=False传递给了表单save; 这会在内存中创建一个实例,但不会将其发送到数据库。 如果你希望这个工作,你将不得不删除commit=False并接受两次保存到db的(微小)成本。 AutoFields are set by the database itself, so don't get a value until after you save. But you have not saved at ...
-
我能够解决这个问题。 问题是在django设置文件中定义的HAYSTACK_ID_FIELD,因为我的字段名称(id)与默认的haystack字段发生冲突。 http://django-haystack.readthedocs.io/en/v2.4.1/settings.html#haystack-id-field 我将我的字段名称更改为其他内容并删除了此设置,一切似乎都正常。 请注意,即使我更改了我的字段名称但未从设置文件中删除此条目,它仍然会给我错误。 在github问题上查看此错误的完整跟踪https ...
-
soup.find()方法找不到匹配的标记,并返回None 。 [...]项访问语法查找__getitem__方法,这是AttributeError的源: >>> None[1] Traceback (most recent call last): File "
", line 1, in TypeError: 'NoneType' object has no attribute '__getitem__' 明确地测试None : Version = soup.find( ... -
它可能只是一个依赖问题。 Apply all migrations: person, auth, ..., organization, account, candidate, ... 您的要求如下:candidate.Profile需要person.Person和person.Person需要auth.User 您不需要再次运行makemigrations auth.User。 所以做以下事情: ./manage.py makemigrations profile ./manage.py makemig ...
-
它应该在模型定义中。 因为它使用模型的元类的__new__方法进行处理。 class Alpha(models.Model): ... objects = MyManager() It should be inside the model definition. Because it's handling with the __new__ method of model's metaclass. class Alpha(models.Model): ... objects ...
-
如何捕获 - 'NoneType'对象没有属性'something'(How to catch - 'NoneType' object has no attribute 'something')[2024-02-10]
您可以使用返回True或False的hasattr(object,name)方法。 如果您尝试访问不存在的属性,您将始终收到异常。 https://docs.python.org/2/library/functions.html#hasattr 如果您仍希望捕获异常,那么只需执行一个异常类型为'AttributeError'的try / catch块 you can use the hasattr(object, name) method which returns True or False. If yo ... -
找到解决方案 # PROBLEM PART改变了: sports_formset = SportTypeFormSet(data=request.POST, instance=company_profile) sports_formset.save() 通过提供company_profile我们让Django找出使用什么样的content_type和object_id 。 Found solution. The # PROBLEM PART is changed: sports_formset = Spo ...
-
首先: __new__方法应命名为__init__ 。 删除全局_host等行 然后更改__init__方法: self.host = host self.userid = userid etc. 并更改GetDataStore : conn = _mssql.connect(server=self.host, user=self.userid, etc.) 这应该够了吧。 我建议你阅读一下面向对象的Python。 First of all: The __new__ method should be n ...
-
我认为这有点棘手。 将此方法添加到BlogRssFeed def get_feed(self, obj, request): self.custom_var = request return super().get_feed(obj, request) 然后 ServiceStatisticsAdd(self.custom_var).add('rss', rss_reference, kwargs) I think it is a bit tricky. Add this method ...
-
更新了views.py。 @login_required def taskadd(request): if request.method=='POST': form=taskaddform(request, request.POST,request.FILES,request.user) if form.is_valid(): new_form=form.save(commit=False) new_form.creat ...