Starting SignalR Hub with two IFrames - signalr

I'm having two frames loading 2 different pages in my project. One page will be a main page which remains unchanged and the second page will get changed based on the user navigation from a menu. I want to utilize SignalR on the main page to perform real time updates. Similarly I want to update in some of the pages (not all) which will be loaded in frame 2 on demand. Hence I have started the hub on main page and performing real time updates. How can I call the SignalR functions in the page available in frame 2? Because according the posts i should start the hub only once in my project (i can still do it, but will create a different connection, which I dont want). If I'm trying to utilize the hub function in page 2 without starting the hub I'm getting the error Uncaught Error: SignalR: Connection must be started before data can be sent. Call .start() before .send() at the client side.
Please help me on how to call the hub methods on page 2 without starting it again. Thanks in advance.

I'm answering my own question. After chatting with experts in JabbR for SignalR, I found out that I have to start the connection on each iframes, no other option available. Please see the Chat history below,

Related

Asynchronous ADO command execution, how to close the connection?

The webapp which I’m working on does some data manipulation at the back-end after a user clicks button. This process takes a long time to complete causing the browser to timeout. Therefore I’ve introduced an asynchronous ADO command which causes the page response immediately while the back-end process keeps running. That page also includes an AJAX call to check the status of the back-end process and when it detects that it is completed another AJAX request gets the result of that process form the back-end. All works as expected.
My question is regarding the ADO connection for this scenario as with the asynchronous execution the connection must not be closed.
Is there a way that I can reference the same connection object from another page (the result page requested by AJAX call) and close it ? Or should I just leave it for the server to kill it off eventually.
I was researching a bit for this answer with no success.
Is there a way that I can reference the same connection object from
another page
How about saving async connection in Session("xxx") variable?

asp.net page wait others server side / asynchrone page

I created an asp.net page for waiting ajax. I have one page creating something that takes 30 seconds. On every step I change a session value.
I have another page for ajax, returning the session value for showing the percentage of creation. But, I dont know why, my ajax page awaits the end of the creation of my first page. So I only get the 100% at the end.
Maybe it's because I use VS development server and not IIS server. If this is the problem, can I change settings of the development server for asynchrone execution?
Or is it something else?
WebForms are not ideal for asynchronous operations.
Add SignalR to your project and use a Hub to push status data back to your page to update the current state of the process you are running Asynchronously.
An example of a technique to perform this type of asynchronous notification is covered in my blog post titled "A Guide to using ASP.Net SignalR with RadNotifications"
Don't use ASP.Net session state to do that. It has an implicit reader/writer lock around it, meaning your other call is probably blocking until your process finishes. You can try storing your status in a database or the cache, but it would probably be better to redesign the interaction.

HotTowel (Durandal really) and SignalR initialisation

So I'm integrating SignalR and HotTowel, although really I think this is a matter of how to integrate with Durandal itself.
The issue is I have obviously multiple views. Some of these views I want to respond to SignalR messages. The question is how to do this integration considering that SignalR events have to be started before I call SignalR's hub start method.
So take the example I have view1 and view2. I want each to do something when a SignalR message is received and in the context of that view (so let's say update the DOM somehow). It's an SPA obviously so calling the SignalR start method for each view seems like a bad idea, so starting SignalR once at boot sounds like the right plan, but at that point my views may not have been loaded, and still how would I ensure that my events have the right context for the page.
This is based on my understanding that all events for SignalR have to be registered before I call start. Any thoughts clever people of StackOverflow?
Edit to expand on the problem
Part of the website involves uploading files for parsing and processing to import into a database. I have created a view where the file is selected and uploaded (using FineUploader) to a WebApiController. The controller does the basic steps of checking the uploaded file and then starts an async task to actually do the parsing and processing, while immediately returning the basic "Yep that uploaded fine" message.
This causes the list of 'in progress' files to refresh and the file appears with an 'Uploaded' status. As the async task occurs, the file is parsed, then processed against a rules system, and then finally imported into another back end data store. As each of these status changes occur, SignalR sends messages to the client to notify them of these changes, and thus update the status against the filename. In order for this to occur I must attach a function to the event as it received in SignalR. That even needs some kind of reference to my view (actually viewmodel) so it can update the correct value.
As SignalR should be started once with a call to hub.Start(), I am trying to do it during the 'boot' phase. However when my SPA starts, that view has not been loaded, and therefore neither has that viewmodel, and therefore my function that is responsible for initialising SignalR can have no understanding of the view/viewmodel it must update.
Examples I've seen on using SignalR show it being used in one view, but that doesn't really work surely if you need it in multiple views (you can't just keep calling hub.start() can you)?
Sorry, if this still doesn't make sense I'll post some code or something.
If you use
$.connection.myHub.on("myMethod", function (/* ... */) { /* ... */ });
instead of
$.connection.myHub.client.myMethod = function (/* ... */) { /* ... */ };
you can add client-side hub methods after calling $.connection.hub.start();

What is the best way to implement a inter-qwebview communication?

Overview:
I am trying to create a PoC application that mimics WebIntents-like feature.
So, in my Qt application, I create two QWebviews launching two different webApps. Now let's call them apps A and B.
Scenario:
Main Application creates two QWebViews each launching an App i.e. AppA, AppB.
App A is programmed to fetch some data via AJAX, automatically.
App B also needs part of that data. AppB simply displays a button (HTML) called .
Note: Since, AppA already has that info, I would like the AppB to invoke a JavaScript API which was injected into it's(appB) DOM by means of addToJavaScriptWindowObject() method call when the QWebView was launched.
App-A completed the Ajax Call and indicates the completion in its WebView.
User clicks the button in AppB,
App B invokes that JavaScript API i.e. fetcData({source: "AppA");
Now the control is in the QT-world:
Question: the Control is in the context of AppB, How should I communicate with the WebView in AppA -- i.e. AppB asks AppA: hey AppA, please give me that data that you have fetched?
Can Signals and Slots help me here? Or should I use some other form of IPC.
I read this page: http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html, but I still didn't get a hint for a solution for my problem.
Another related question: Are QWebViews created in their own threads ?
Can't you just emit some sort of signal from AppB that basically says, "Hey, I finished fetching my data if anyone wants it" or am I missing something? It would happen at the end of AppB::fetchData().
All you have to do after that is connect any interested objects to that signal.

creating a one on one chat inside an asp.net website

i would like to create a facebook like one on one chat within an asp.net website, but i cant figure out the mechanism or how it would work.
so far i only have a database table for it designed like this:
id | user1 | user2 | datetime | message
how do i get started, thanks.
I'd consider utilising Signal R for this type of feature - see this guide on implementing a chat feature with signal r - should remove a lot of pain from the development process http://geekswithblogs.net/jeroenb/archive/2011/12/14/signalr-starter-application.aspx
take a look at this:
Simple Chat Application in ASP.NET
The most efficient method to build a chat in asp.net is to use a IHttpAsyncHandler and ajax requests.
Here is a completely working project that implements this, along with ajax.
An async request allows you to delay the response of a request till an external event occurs.
A user makes a call to this handler and waits till someone sends him a message.
Messages are delivered as soon as you send them to a user.
On receiving a message the client makes another request and waits for the next message.
This is a lot more efficient than polling the site to check if messages have arrived.
Using the async handler also ensures that no asp.net threads are wasted waiting while a user waits for messages to come.
This ensures that you chat can scale well even as the number of users of the site goes up.

Resources