signalr-hub

How to send Parameter/Query in HubConnection SignalR Core

别说谁变了你拦得住时间么 提交于 2020-01-12 07:00:24
问题 I'm trying to add parameter into connection to signalr. I'm using Builder to create my Client connection and start it: var connection = new HubConnectionBuilder() .WithUrl("http://10.0.2.162:5002/connection") .WithConsoleLogger() .WithMessagePackProtocol() .WithTransport(TransportType.WebSockets) .Build(); await connection.StartAsync(); I want to send a simple parameter in this connection: Something Like: "Token": "123" In my server side i think i can take this parameter from HttpContext:

Calling SignalR hub clients from elsewhere in system

前提是你 提交于 2020-01-09 08:27:47
问题 I've set up a SignalR hub to communicate between the server and client. The hub server side code is stored in a class called Hooking.cs. What I want is to be able to call a method defined in Hooking.cs to allow me to broadcast messages to any connected clients from anywhere in my application. It seems that a new instance of Hooking.cs is created for every client/server call, so I had hoped that I would be able to use something like var hooking = new Hooking(); hooking.Test(); with the method

C# MVC - Send message with SignalR from server to Caller

大城市里の小女人 提交于 2020-01-06 15:52:13
问题 I have a request from client to Server using SignalR-2.2.1 . After that request, Server will send the results back to the caller. Here is my JavaScript code : $(document).ready(function () { var myHub = $.connection.signalHub; myHub.client.receive = function (tmp) { var obj = $.parseJSON(tmp); //do something }; $.connection.hub.start().done(function () { $('#xxxxx').click(function () { var form = $("form"); form.submit(); myHub.server.sendSomething(); }); }).fail(function (reason) { //do

how to create a signalR hub proxy in javascript, having hubs in class library?

回眸只為那壹抹淺笑 提交于 2020-01-05 04:13:13
问题 currently, am working on chat application using signalR and agsxmpp library, I have seen many examples how to create a proxy of hub in javascript. however, my architecture is differ from these examples. I have class library and a web project(web forms) Hubs are written in class library, and java script exists in web project, I want to create proxy of hub(written in class library) in java script I have tried a lot. but couldn't find a solution. I have read owin(startup.cs) but still not a

Signalr always falls to long polling in the production server

柔情痞子 提交于 2020-01-04 18:16:42
问题 When i host the application in the server it checks for the server side events and falls back to long polling always. The server hosting environment is Windows Server 2012 R1 and IIS 7.5 Is there anyway if we can solve this issue? https://cloud.githubusercontent.com/assets/9750273/5050991/2f4cb262-6c59-11e4-9e35-db06b432d470.png IE10, Chrome 38.0.2125.111 and Firefox.. In all the 3 browsers i am getting long polling, server sent events is cancelled. As i understand few of them had told if the

SignalR is not loaded. Please ensure jquery.sigalR-x.js is referenced before ~/signalr/js

ⅰ亾dé卋堺 提交于 2020-01-04 04:18:09
问题 I have referenced below two libraries dynamically in my page. When I browse my application below mentioned error did not come in Chrome browser. But in Internet Explorer the error occurs. var signalRLibrary = document.createElement('script'); signalRLibrary.type = "text/javascript"; signalRLibrary.src = 'jquery.signalR-2.1.2.min.js'; document.getElementsByTagName('head')[0].appendChild(signalRLibrary); var signlaRHub = document.createElement('script'); signlaRHub.type = "text/javascript";

Why are messages pushed from an MVC app with SignalR not getting through to the client?

喜欢而已 提交于 2020-01-04 02:41:17
问题 I have a simple SignalR hub application, using MVC4/C# on the server end, hosted in an Azure Web Role (single instance, in the emulator, with an http input endpoint), and TypeScript compiled to JS on the client. I have a gallery of images that a number of clients may upload to, and when somebody uploads then I want any other connected clients to receive a message telling them this has happened and giving them the chance to refresh, similar to the way you are notified about a new answer to a

Is it possible to return a pre-encoded JSON string in a SignalR hub method?

两盒软妹~` 提交于 2020-01-02 07:05:21
问题 In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? 回答1: Looking at this here: We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString

Is it possible to return a pre-encoded JSON string in a SignalR hub method?

五迷三道 提交于 2020-01-02 07:05:13
问题 In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? 回答1: Looking at this here: We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString

SignalR request pipeline, Hub lifetime

萝らか妹 提交于 2020-01-02 05:37:35
问题 I am starting on signalR with asp.net webapi, and I am trying to understand the whole signalR request/connection pipeline and what is the lifetime of the hub and who creates and dispose the hub instance (does it gets created on every communication between client and server?) One of the reason is that we need to understand how we should be using an IoC contain in signalR request scenario, how we control the lifetime of the dependency correct specifically the ISession or DBContext . 回答1: Hubs