{$Wap} | 网站首页 | 电脑资料库 | wap资源库 | 建站资源库 | 茂名合租网 | 下载中心 | 美图资源库 | 茂名资源网商城 | 
广告载入中...
〒 您现在的位置: 茂名资源网 >> wap资源库 >> wap教程 >> WAP网站开发 >> wap资源库正文
WAP聊天室机器人设计 【字体:
作者:佚名    wap资源库来源:不详    点击数:    更新时间:2007-3-31
广告载入中...

1。前段时间开发了个WAP上聊天室的机器人。流程图如下

2.数据模型

3.Main Source:

RobotBeat.java

 package pubchat;

import java.io.*;
import java.net.*;
import java.util.*;
import pubchat.dao.*;
import pubchat.client.*;
import org.apache.log4j.Logger;
import pubchat.wap.ClientTest;

public class RobotBeat extends Thread {
    Logger log = Logger.getLogger(RobotBeat.class);
    int timediff; //组件重画的间隔时间
    volatile boolean shouldrun; //设为false为停止线程
    ChatDAO chatDao = null;
    RobotDAO robotDao = null;
    Vector roomVec = null;
    int roomSize = 0;
    Vector robotVec = null;
    boolean clearFlg = false;
    private static int wordsCount = 0;

    public RobotBeat() {
        this.timediff = 1 * 60 * 1000;
        this.shouldrun = true;
        System.out.println("机器人线程启动。。。。。");
        this.chatDao = new ChatDAO(true);
        this.robotDao = new RobotDAO(true);
        this.roomVec = chatDao.selectChatRoom(); //大类,小类,房间id, 房间名,房间类
        this.roomSize = this.roomVec.size();
        this.robotInit();
    }

    public void run() {
        while (shouldrun) {
            try {
                //robotInit();

                //robotClear();
                //robotInit();
                wordsCount++;
                long start = System.currentTimeMillis();
                System.out.println("Sleep start:"+start);
                sleep(timediff);
                long end = System.currentTimeMillis();
                System.out.println("Sleep End:"+end);
                //随机说话
                //      if (this.getProperty()==Driver.FLT_ROBOT) {
                //机器人线程
                if (wordsCount%20==0) {
                    System.gc();
                    robotClear();
                    robotInit();
                } else {
                    ClientTest content = new ClientTest();
                    for (int i = 0; i < robotVec.size(); i++) {
                        String sayId = (String) robotVec.elementAt(i);
                        String sayWords = this.robotDao.selectRandomWord();
                        System.out.println("机器人 " + sayId + ":" + sayWords);
                        content.say(sayId, sayWords);
                    }
                    content = null;
                }

[1] [2] [3] [4] [5] 下一页  

收藏此页到:[天极网摘]  [和讯网摘]  [新浪VIVI]  [365key]  [博采中心]  [网摘中国]  [5Seek]  [狐摘 ]  [365Fav]  [热门 ]  [人人网摘]  [我摘]  [YouNote]
广告载入中...

注明
☉本站所有软件和资料大多来自互联网收集整理,仅供学习和研究使用。如有侵犯您版权的,请来信指出,本站将立即改正。
邮址:diyb208%21cn.com请将%换成@
☉下载的压缩包如需要密码的,密码统一为:www.0668idc.com
☉茂名资源网不承担用户因使用这些下载资源和技术教程对自己和他人造成任何形式的损失或伤害。
☉资源下载请使用[FlashGet]下载,否则可能出现下载不了的情况;解压缩请使用[Winrar]。

  • 上一个wap资源库:

  • 下一个wap资源库:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:落叶有声
    管理员通信方式:信箱地址:diyb208@21cn.com QQ:84805309