LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 854|回复: 0

用JQL2005开发QQ客户端,超时~

[复制链接]
发表于 2006-4-4 11:08:54 | 显示全部楼层 |阅读模式
/**
* 创建日期 2006-3-11
*
* 作者 Foxty
*
* 描述
*/
package foxty.study.qq;

import edu.tsinghua.lumaqq.qq.QQClient;
import edu.tsinghua.lumaqq.qq.beans.QQUser;
import edu.tsinghua.lumaqq.qq.events.IQQListener;
import edu.tsinghua.lumaqq.qq.events.QQEvent;

public class QQTest
{

        public QQTest()
        {
                super();
                // TODO 自动生成构造函数存根
        }
       
        public static void main(String args[])
        {
               
                QQClient client = new QQClient();
                client.addQQListener(new QQAdapter(client));
                QQUser user = new QQUser(3481504,"qq13986289120");
                user.setUdp(true);
                client.setUser(user);
                client.setLoginServer("sz.tentcent.com");
                //client.setLoginRedirect(true);
                try
                {
                        client.login();
                        System.out.println("Loging.....");
                        Thread.sleep(30000);
                        client.sendIM(46960550,"Test");
                }catch(Exception e)
                {
                        e.printStackTrace();
                }
                System.out.println("logout!");
                client.logout();
                client.release();
        }

}

class QQAdapter implements IQQListener
{
        QQClient client;
       
        public QQAdapter(QQClient client)
        {
                this.client = client;
        }
        /*
         * @see edu.tsinghua.lumaqq.qq.events.IQQListener#qqEvent(edu.tsinghua.lumaqq.qq.events.QQEvent)
         */
        public void qqEvent(QQEvent event)
        {
                System.out.println("qqevent!"+event.type);
                switch(event.type)
                {
                        case QQEvent.QQ_LOGIN_SUCCESS:
                                System.out.println("login success!");
                                client.sendIM(46960550,"在吗?");
                                client.sendIM(46960550,"hello");
                                break;
                        case QQEvent.QQ_LOGIN_PASSWORD_ERROR:
                                System.out.println("password error!");
                                break;
                        case QQEvent.QQ_LOGIN_UNKNOWN_ERROR:
                                System.out.println("unknown error!");
                                break;
                        case QQEvent.QQ_SEND_IM_SUCCESS:
                                System.out.println("send message success!");
                                break;
                }
        }
       
}


以上是代码,每次登陆后,事件监听里面只接受到了33号时间,发现是QQ-_OPERATION_TIMEOUT事件。很是奇怪。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表