很多的sns网站都提供了短消息功能。而且,如果我们在线的话会很快的收到好友的短消息。
这里介绍一种客户端的方法,简单实现。

主要的表:
user
    :Uid UName Password 三个字段
Message
    :Mid, SenderId, ReceiverId, State, Detail(SenderId和 ReceiverId)都是外键且对应user表中的Uid。


主要的思路很简单:用js每隔五秒钟发送一次ajax请求,获取当前用户在Message表中State为未读取(这里约定为数字1)且ReceverId为当前用户ID的Message 记录的数量。

页面的代码:
<%@ Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="MIDemo._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <!-- 两个js脚本文件-->
    <script type="text/javascript" src="SqlHelp/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="SqlHelp/GetMessageCount.js"></script>
</head>
<body>
    <form )]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class FindNewMessage : IHttpHandler
   

相关文章:

  • 2022-12-23
  • 2021-04-06
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-09-23
  • 2021-06-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-09-16
相关资源
相似解决方案