Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ChatController.cs - An Async Chat Controller for MVC 3
using System.Web.MVC
public class ChatController : AsyncController
{
[AsyncTimeout(ChatServer.MaxWaitSeconds * 1002)]
public void IndexAsync()
{
AsyncManager.OutstandingOperations.Increment();
ChatServer.CheckForMessagesAsync(msgs =>
{
AsyncManager.Parameters["response"] = new ChatResponse
{
messages = msgs
};
AsyncManager.OutstandingOperations.Decrement();
});
}
public ActionResult IndexCompleted(ChatResponse response)
{
return Json(response);
}
[HttpPost]
public ActionResult New(string user, string msg)
{
ChatServer.AddMessage(user, msg);
return Json(new
{
d = 1
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.