Hi I wanna make a website preferably using asp.net 3.5 in c#. In this web app, I need to push messages very frequently. (like if sender sends a message, it should immediately reflect to the receivers). So more like chat application but not bidirectional.
My question is how can i refresh receivers webpage immediately?
or How can i push message to the receivers immediately?
any help is highly appreciated?
I'm guessing you're talking about features like Facebook Chat. According to various facebook dev blog posts, I believe they use ajax to make a long polled request; meaning as soon as one user sends a message, theres another ajax request made which isn't responded to by the server until there's something to report (i.e. a new message). This is often called "Comet".
Note: do NOT attempt to do this on a standard server setup - most server software starts a new thread for each request. You'll need custom server software to avoid this. Unfortunately, I've searched for hours in the past and can't find a definitive answer to which software accomplishes this best.
You might consider using a Comet Look at the "implementation" section for some ideas.
Related
I want to create a cross platform chat app with backend in c#
I searched for an approach to do so and found that I can do so with http requests to handlers on my server and use the response accordingly.
So till now I made the handlers which can add users, login, send and receive messages using database for storage.
Now I am making android client for that and to get messages for user I need to do http requests at a specific interval (3 seconds).
I feel it is not a good approach to do this. I am making this app for a target audience of nearly 30000. They would be able to chat one on one at a single session.
I just want to know if I am going in right direction or There is far more better ways to make chat apps using backend.
I have heard about wcf but I am not clear with what approach should I take. Please guide me about approaches for chat application.
Edit
An example of little working of any famous chat app like whats app, facebook messenger would be a great help.
Thanks.
You could do it with HTTP, but I'd suggest using TCP instead. There's a very solid base for a C# based TCP server on codereview right here which will outline how to deal with Socket objects how to handle connections properly.
The main perk of going about it this way is that you can connect your client to the server, and the client can be virtually any language, it doesn't have to be C# - as long as the language supports sockets, you'll be fine.
On top of that you can have the client listen to the server, which removes the need of polling the server for new messages every couple of seconds; the client socket will receive data when the server sends it, and you can handle it right away, nearly in real-time, whereas if you'd poll the server for new messages over HTTP every - say 3 seconds - you'll always end up with a delay in your chat service, which is something I think you will want to avoid.
See the code sample on CodeReview I linked above, and read up on how Sockets work in C#, how TCP works in terms of guarantees (TCP guarantees that whatever is sent over it will end up on the other side in the same order, but not necessarily in one packet, etc) and I'm pretty confident you'll be able to make a excellent chat app if you put it all to good use.
Edit: I just noticed the WCF tag on your post. I'd personally steer clear of it for this specific project since you want to achieve cross-platform support; try going as low-level as you possibly can for that.
I have an intranet/extranet app which calls the server to do some VERY LONG calculations. The client should be able to keep surfing the site and doing his stuff, until a message pops up saying the calculation has ended and asking him if he wants to go back to the page to see the results.
If so, the client must be redirected to that page, the data must be retrieved the from the server and displayed. If the user cancels the action, the data set must be cleared.
How do I send a message to the client from C# and how do I catch it? Is it possible?
Thanks
Reactive Extensions (Rx) for .NET deals with exactly this kind of problem. It allows for "push" notifications of remote events.
Here is a blog post that introduces Rx over ASP.NET:
http://weblogs.asp.net/podwysocki/archive/2010/02/16/introduction-to-the-reactive-extensions-to-javascript.aspx
Here's an entire RxJS library:
http://reactive-extensions.github.io/RxJS/
Yes, sending messages from server to client via http possible with using web-sockets or longpolling technologies.
i'm trying to make a chat application using c# that connects to a web server in order to check if there are messages available.
I've tried that by creating HttpWebRequest to check for messages every second, but i notice that it's not good for the server, imagine if there are thousands of users and each user sends an HttpWebRequest every second, that would be heavy.
I heard something about synchronous connection but i think it also sends the same number of HttpWebRequest, (i'm not sure about this part).
So please does any one know the right method for a chat application?
Perhaps SignalR might be useful in your case.
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
Actually the most typical tutorial using this technology is web chat.
Use the Remoting.Net
see this :
http://www.codeproject.com/Articles/62813/NET-Remoting-Events-Explained
http://www.codeproject.com/Articles/12586/Remote-Execution-Using-NET-Remoting
I am trying to create a program that will be passed input data from events a user fires from a webpage on their browser. I am aiming at google-chrome currently with the program being in either java or C#. I know this is possible because Spotify does this, so does the Battlefield 3 PC gui. How can I go about doing this? Does the user need to install an extension or can I get that information straight from google-chrome? Note: The webpage is not being run on localhost.
You're going to want to look into web sockets. Web sockets are just cool. I got a huge grin on my face the first time I got demo working. :D
Here's a tutorial that helped me out:
http://www.developerfusion.com/article/143158/an-introduction-to-websockets/
You can create a socket listen in your appilcation then connect to it from javascript, passing whatever data you desire. It's nicer then ajax as it's a persistent open connection and you don't have the overhead of http calls.
Ok I want to build a simple chat app where people can go a url, type in a name and a message and click submit and it will basically show that message to everyone that is current connected.
Firstly i would like to state i've had zero experience in sockets programming and the like. I'm simply a web 2.0 person building websites with css/html/js/ajax and backend i have asp.net on vb and sql server for database.
The many tutorials i've read linked me to http://superwebsocket.codeplex.com/
I've downloaded it, but im totally lost. i can't get the samples working and i don't even know what to run.
So basically coming from an ajax background, i was wondering why do we even need to download any additional stuff to do web sockets? I mean in ajax i can simply create a asd.aspx file and use Response.Write(text) (text based on the input which are available through dissecting the url) and voila, the server side is done, all that's left is just to create new XMLHttpRequest and stuff in the client side.
So ok I'm not worried about the client side part of Web Sockets. but the server side part of web sockets is just difficult. so in the client side i have this: ws://localhost:8080/websocket. Is it true that it will work if is also an .aspx file as such: ws://localhost:8080/websocket.aspx ?
I'm wondering so how do i continue from here? in Ajax i will supply parameters from client in the url as such: page.aspx?a=1&b=2 and do output in the server using Response.Write it's all clear but how do we do it in web sockets?
I mean of course i do not demand a full explanation with a forum reply but if someone could link me to a tutorial/book that actually does explain these stuff it would be great.
Microsoft's implementation has a full chat client sample for both HTML5 and pure C#.
http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/download
I'm guessing this implementation is what would end up in ASP.NET and .NET framework so I'm using it because of that.