博文

.net_Ajax聊天室项目系列解读(Room.cs)(2008-10-31 17:23:00)

摘要:using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Threading;
using System.Collections.Generic;
//聊天室
public class Room
{
    private static readonly long ClearUserInterval = 300000;//调用定时函数的时间间隔5分钟
    private static readonly TimeSpan ExpiringInterval = new TimeSpan(0, 10, 0);//过期的区间10分钟
    private static readonly int MessageLimit = 50;//存储的信息的最大数量
    private Dictionary<string, ChatUser> chatingUsers = null;//聊天用户的集合
    private LinkedList<Msg> chatMessage = null;//消息集合
    private Timer timer = null;
    private object islock = new object();
    public Room()
    {
        this.chatingUsers = new Dictionary<string, ChatUser>();
        t......

阅读全文(2327) | 评论:0

.net_Ajax聊天室项目系列解读(login.aspx.cs)(2008-10-31 09:52:00)

摘要:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Login : System.Web.UI.Page
{
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);//停留3秒
        string userName = this.txtUserName.Text.Trim();//账号
        string password = this.txtPassword.Text.Trim();//密码
        string retypePwd = this.txtRetypePwd.Text.Trim();//重新输入的密码
        //用户在聊天室中,但此次输入的密码不正确,提示
       if (Room.Instance.UserIsChatting(userName)&&am......

阅读全文(2686) | 评论:0

.net_Ajax聊天室项目系列解读(login.aspx)(2008-10-31 09:51:00)

摘要:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>聊天室登录</title>
    <link href="./js/chat.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-color: WhiteSmoke">
    <form id="form1" runat="server">
        <div style="text-align: center">
            <span style="font-size: 14pt; color: #3300ff"><strong>
                <br />
                聊天室登录<br />
            </strong></......

阅读全文(2925) | 评论:0

.net_Ajax聊天室项目系列解读(演示图片)(2008-10-31 09:49:00)

摘要:

......

阅读全文(2086) | 评论:0

.net_Ajax聊天室项目系列解读(介绍)(2008-10-31 09:39:00)

摘要:介绍:本例采用asp.net2.0+ajax技术实现,不用数据库,采取2.0新概念Dictionary、LinkedList集合实现数据的处理. 本例视图:
共有3个实体类,消息类Msg   聊天室类Room 用户类User  该例涉及泛型理论, 可参考: http://blog.programfan.com/blog.asp?blogid=4826&columnid=7313......

阅读全文(1782) | 评论:0

C++入门第7章7.1.5指向结构体变量的指针[例7.3 ](2008-10-24 12:26:00)

摘要:  例7.3 指向结构体 变量的指针的应用。 #include <iostream> #include <string> using namespace std; int main( ) {struct Student             //声明结构体类型student { int num; string name; char sex; float score; }; Student stu;                //定义Student类型的变量stu Student *p=&stu;            //定义p为指向Student类型数据的指针变量并指向stu stu.num=10301;              //对stu中的成员赋值 stu.name=″Wang Fun″;        //对string变量可以直接赋值 stu.sex=′f′; stu.score=89.5; cot<<stu. num<<″ ″<<stu.name<<″ ″<<stu.sex<<″ ″<<stu.score<<endl; cout<<(*p)>num<<″ ″<<(*p).name<<″ ″<<(*p).sex<<″ ″<<(*p).score<<endl; ......

阅读全文(3111) | 评论:1

C++入门 第7章 7.1.5 指向结构体变量的指针(2008-10-24 12:25:00)

摘要:  一个结构体变量的指针就是该变量所占据的内存段的起始地址。可以设一个指针变量,用来指向一个结构体变量,此时该指针变量的值是结构体变量的起始地址。指针变量也可以用来指向结构体数组中的元素。 1. 通过指向结构体变量的指针引用结构体变量中的成员 下面通过一个简单例子来说明指向结构体变量的指针变量的应用。 ......

阅读全文(1798) | 评论:1

C++入门 第7章 7.1.2.3结构体数组应用举例[2](2008-10-24 12:24:00)

摘要:  程序定义一个全局的结构体数组leader,它有3个元素,每一元素包含两个成员,即name(姓名)和count(得票数)。在定义数组时使之初始化,使3位候选人的票数都先置零。见图7.6。
  在这个例子中,也可以不用字符数组而用string方法的字符串变量来存放姓名数据,程序可修改如下:   #include <iostream> #include <string> using namespace std; struct Person { string name;                     //成员name为字符串变量 int count; }; int main( ) { Person leader[3]={″Li″,0,″Zhang″,0,″Fun″,0}; int i,j; string leader_name;               // leader_name为字符串变量 for(i=0;i<10;i++) {cin>>leader_name;  for(j=0;j<3;j++) if(leader_name==leader[j].name) leader[j].count++;  //用“==”进行比较  } cout<<endl; for(i=0;i<3;i++) {cout<<leader[i].name<<″:″<<leader[i].count<<endl;} return 0; } ......

阅读全文(2037) | 评论:0

C++入门 第7章 7.1.2.3结构体数组应用举例[1](2008-10-24 12:23:00)

摘要:  下面举一个简单的例子来说明结构体数组的定义和引用。 例7.2 对候选人得票的统计程序。设有3个候选人,最终只能有1人当选为领导。今有10个人参加投票,从键盘先后输入这10个人所投的候选人的名字,要求最后输出这3个候选人的得票结果。 可以定义一个候选人结构体数组,包括3个元素,在每个元素中存放有关的数据。 程序如下: #include <iostream> struct Person                              //声明结构体类型Person { char name[20]; int count;   }; int main( ) { Person  leader[3]={″Li″,0,″Zhang″,0,″Fun″,0};     //定义Person类型的数组,内容为3个候选人的姓名和当前的得票数 int i,j; char leader_name[20];            //leader_name为投票人所选的人的姓名 for(i=0;i<10;i++) {cin>>leader_name;             //先后输入10张票上所写的姓名  for(j=0;j<3;j++)              //将票上姓名与3个候选人的姓名比较 if(strcmp(leader_name,leader[j].name)==0) leader[j].count++; /......

阅读全文(2896) | 评论:1

C++入门第7章7.1.2结构体数组的初始化(2008-10-24 12:21:00)

摘要:  与其他类型的数组一样,对结构体数组可以初始化。如 struct Student                  { int num; char name[20]; char sex; int age; float score; char addr[30]; }sty[3]={{10101,″Li Lin″,′M′,18,87.5,″103 Beijing Road″}, {10102,″Zhang Fun″,′M′,19,99,″130 Shanghai Road″}, {10104,″Wang Min″,′F′,20,78.5,″1010,Zhongshan Road″}}; 定义数组stu时,也可以不指定元素个数,即写成以下形式:  stu[ ]={{…},{…},{…}}; 编译时,系统会根据给出初值的结构体常量的个数来确定数组元素的个数。一个结构体常量应包括结构体中全部成员的值。 当然,数组的初始化也可以用以下形式: Student stu[ ]={{…},{…},{…}};    //已事先声明了结构体类型Student 由上可以看到,结构体数组初始化的一般形式是在所定义的数组名的后面加上 ={初值表列}; ......

阅读全文(4918) | 评论:1