基本信息
源码名称:asp.net mvc 实时在线聊天系统源码下载(SSE/EventSource)
源码大小:0.64M
文件格式:.zip
开发语言:C#
更新时间:2017-01-01
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using webchat.Database;
using webchat.Filters;
using webchat.Helpers;
using webchat.Models;
namespace webchat.Controllers
{
/// <summary>
/// Handles the main page of the appliaction
/// </summary>
/// <remarks>In order to enter the chat the user must be authenticated
/// <seealso cref="Filters.AuthenticationFilterAttribute"/></remarks>
[AuthenticationFilter]
public class ChatController : Controller
{
/// <summary>
/// Load the initial page where the user can send messages and join additional rooms
/// </summary>
/// <returns>Returns a <see cref="Models.ChatModel"/></returns>
public ActionResult Index() {
ChatModel model = new ChatModel();
model.AllRooms = new RoomsModel();
model.ConnectedRooms = new RoomsModel();
model.Users = MvcApplication.Db.GetUsers();
model.ConnectedRooms.Rooms = MvcApplication.Db.GetRooms((string)Session["nick"]);
model.AllRooms.Rooms = MvcApplication.Db.GetRooms();
MvcApplication.Pub.Publish(Resources.Internals.RoomsEventChannel,
JsonConvert.SerializeObject(MvcApplication.Db.GetRooms()));
return View(model);
}
/// <summary>
/// Log the user out
/// </summary>
/// <returns>Redirects the user to the <see cref="IndexController"/></returns>
public ActionResult Disconnect() {
List<string> rooms = MvcApplication.Db.GetRooms((string)Session["nick"]);
MvcApplication.Db.DelUser(rooms, (string)Session["nick"]);
MvcApplication.Db.DelUserFromGlobalList((string)Session["nick"]);
Session.Abandon();
return RedirectToAction("Index", "Index");
}
}
}