Example #1
0
        /**
         * 程序入口
         *
         */
//    public void loginWb(){
//      client.preloginWb(new QQActionListener() {
//
//			@Override
//			public void onActionEvent(QQActionEvent evt) {
//				// TODO Auto-generated method stub
//				if (evt.getType() == Type.EVT_OK) {
//					//到这里就算是登录成功了
//					ArrayList<String> list = (ArrayList<String>) evt.getTarget();
//					foreach (String string : list) {
//						Console.WriteLine(string);
//					}
//					Console.WriteLine("就算是登录成功微博了");
//
//					new Thread(new Runnable() {
//
//						@Override
//						public void run() {
//							// TODO Auto-generated method stub
//							while(true){
//								try {
//									String sendMsg = new BufferedReader(new InputStreamReader(System.in)).readLine();
//									if(sendMsg.contains("#")){
//										client.pollWbMsg("5175429989", new QQActionListener() {
//
//											@Override
//											public void onActionEvent(QQActionEvent evt) {
//												// TODO Auto-generated method stub
//												if (evt.getType() == Type.EVT_OK) {
//													Console.WriteLine("pllmsg:   "+evt.getTarget());
//												}
//											}
//										});
//									}else{
//										client.sendWbMsg(sendMsg, "5175429989", new QQActionListener() {
//
//											@Override
//											public void onActionEvent(QQActionEvent evt) {
//												// TODO Auto-generated method stub
//												if (evt.getType() == Type.EVT_OK) {
//													Console.WriteLine("发送成功");
//												}
//											}
//										});
//									}
//
//								} catch (IOException e) {
//									// TODO Auto-generated catch block
//									e.printStackTrace();
//								}
//							}
//
//						}
//					}).start();
//
//				}else{
//					Console.WriteLine(evt.getTarget());
//				}
//			}
//		});
//    }

        /**
         * 聊天消息通知,使用这个注解可以收到QQ消息
         *
         * 接收到消息然后组装消息发送回去
         *
         * @throws QQException
         */
        public void processBuddyMsg(QQNotifyEvent evt)
        {
            QQMsg msg = (QQMsg)evt.getTarget();

            List <ContentItem> items = msg.getContentList();

            foreach (ContentItem item in items)
            {
                if (item.getType() == ContentItem.Type.FACE)
                {
                }
                else if (item.getType() == ContentItem.Type.OFFPIC)
                {
                }
                else if (item.getType() == ContentItem.Type.TEXT)
                {
                    Console.WriteLine(" Text:" + ((TextItem)item).getContent());
                }
            }

            // 组装QQ消息发送回去
            QQMsg sendMsg = new QQMsg();

            sendMsg.setTo(msg.getFrom());                   // QQ好友UIN
            sendMsg.setType(QQMsg.Type.BUDDY_MSG);          // 发送类型为好友
            // QQ内容
            sendMsg.addContentItem(new TextItem("hello"));  // 添加文本内容
            sendMsg.addContentItem(new FaceItem(0));        // QQ id为0的表情
            sendMsg.addContentItem(new FontItem());         // 使用默认字体
            client.sendMsg(sendMsg, null);                  // 调用接口发送消息
        }
Example #2
0
        /**
         * {@inheritDoc}
         *
         * 提交验证码
         */

        public void submitVerify(String code, QQNotifyEvent verifyEvent)
        {
            QQNotifyEventArgs.ImageVerify verify =
                (QQNotifyEventArgs.ImageVerify)verifyEvent.getTarget();

            if (verify.type == QQWpfApplication1.bean.QQNotifyEventArgs.ImageVerify.VerifyType.LOGIN)
            {
                ProcModule mod = (ProcModule)getModule(AbstractModule.Type.PROC);
                mod.loginWithVerify(code, (AbstractActionFuture)verify.future);
            }
        }
Example #3
0
        /**
         * {@inheritDoc}
         *
         * 通知事件
         */

        public void fireNotify(QQNotifyEvent evt)
        {
            if (notifyListener != null)
            {
                try {
                    notifyListener.onNotifyEvent(evt);
                } catch (Exception e) {
                }
            }
            // 重新登录成功,重新poll
            if (evt.getType() == QQNotifyEvent.Type.RELOGIN_SUCCESS)
            {
                beginPollMsg();
            }
        }
Example #4
0
        /** {@inheritDoc} */
        public void onNotifyEvent(QQNotifyEvent evt)
        {
            MethodInfo m = methodDictionary[evt.getType()];

            if (m != null)
            {
                try {
                    m.Invoke(proxyObject, new Object[] { evt });
                } catch (Exception e) {
                }
            }
            else
            {
            }
        }
Example #5
0
        /**
         * 需要验证码通知
         *
         * @throws IOException
         */
        public void processVerify(QQNotifyEvent evt)
        {
            QQNotifyEventArgs.ImageVerify verify = (QQNotifyEventArgs.ImageVerify)evt.getTarget();
            BufferedStream stream = new BufferedStream(verify.image.StreamSource);
            FileStream     file   = File.Create("C:\\Users\\leegean\\Desktop");
            int            read   = -1;

            while ((read = stream.ReadByte()) != -1)
            {
                file.WriteByte((byte)read);
            }
            file.Dispose();
            Console.WriteLine(verify.reason);
            Console.WriteLine("请输入在项目根目录下verify.png图片里面的验证码:");

            String code = Console.ReadLine();

            client.submitVerify(code, evt);
        }
Example #6
0
 /**
  * 被踢下线通知
  *
  */
 protected void processKickOff(QQNotifyEvent evt)
 {
 }
Example #7
0
        /**
         * {@inheritDoc}
         *
         * 刷新验证码
         */

        public AbstractActionFuture freshVerify(QQNotifyEvent verifyEvent, QQActionListener.OnActionEvent listener)
        {
            LoginModule mod = (LoginModule)getModule(AbstractModule.Type.LOGIN);

            return(mod.getCaptcha(account.getUin(), listener));
        }