pushlet实现webQQ即时通信

阅读更多

后台维护界面展现:


pushlet实现webQQ即时通信_第1张图片
                                                                 后台首页

 

 

 


pushlet实现webQQ即时通信_第2张图片
                                                      账户及其人员列表

 

人员的组织及其所在群组的维护页面就不在展现下面展现客户端。

 


pushlet实现webQQ即时通信_第3张图片
                     用户登录

 


pushlet实现webQQ即时通信_第4张图片
               鼠标悬停

 

 


pushlet实现webQQ即时通信_第5张图片
                  维护状态

 

 


pushlet实现webQQ即时通信_第6张图片
                   鼠标右键

 

 


pushlet实现webQQ即时通信_第7张图片
                                               查看人员信息

 

 

 


pushlet实现webQQ即时通信_第8张图片
                                            查看聊天记录

 

 


pushlet实现webQQ即时通信_第9张图片
                                          维护个人资料

 

 

 


pushlet实现webQQ即时通信_第10张图片
                                           聊天窗口

 

 

 


pushlet实现webQQ即时通信_第11张图片
                                         互相附件传送

 

 


pushlet实现webQQ即时通信_第12张图片
                 IM实现消息提醒

 


pushlet实现webQQ即时通信_第13张图片
                                  实现群组之间的聊天

 

以上是IM(即时通信)一些基本功能的简介,好了就先到此为止吧。。。。。

在Pushlet的应用方面希望可以与大家相互交流,互相学习。

 

 

 

 

JavaScript两种发送消息的方式不用多说

1、Ajax保持心跳的即时通信

2、往前台输送HTML的即时通信

 

下面贴Java实现即时通信的代码

package com.jlee.im;

import java.util.Map;

import nl.justobjects.pushlet.client.PushletClient;
import nl.justobjects.pushlet.client.PushletClientListener;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.Protocol;


public class SystemChatEngine extends Thread implements PushletClientListener, Protocol {
//	private static SystemChatEngine  systemChatEngine = new SystemChatEngine("http://localhost:8888/im/pushlet.srv");

	private static SystemChatEngine engine = null ;
	private PushletClient pushletClient;
	private Map attributemap ;
	private String aHosturl=null;
	private String SUBJECT = "/pushlet/ping";
	private String imSubject = null;

	private SystemChatEngine(String aHosturl, String subject, String imSubject, Map map) {
		this.aHosturl = aHosturl;
		this.SUBJECT = subject ;
		this.attributemap = map ;
		this.imSubject = imSubject ;
	}
	
	public static SystemChatEngine getInstance(String aHosturl, String subject ,String imSubject ,Map map){
		if(engine==null){
			engine = new SystemChatEngine(aHosturl,subject,imSubject,map) ;
			engine.start() ;
		}
		return engine ;
	}
	
	public void run() {
		try {

			pushletClient = new PushletClient(aHosturl);
			pushletClient.setDebug(false);
			
			pushletClient.setUid(attributemap.get("uid")) ;
			
			pushletClient.join();
			pushletClient.listen(this, Protocol.MODE_PULL,SUBJECT);

			System.out.println("pushletClient started");
			
			pushletClient.publish(imSubject, attributemap);
			
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
	}

	/** Error occurred. */
	public void onError(String message) {
		System.out.println(message);
	}

	/** Abort event from server. */
	public void onAbort(Event theEvent) {
	}

	/** Data event from server. */
	public void onData(Event theEvent) {
		String meSessionID = theEvent.getField("uid");
	}

	/** Heartbeat event from server. */
	public void onHeartbeat(Event theEvent) {
	}

	public void onRefresh(Event theEvent) {
	}

	public void onJoinListenAck(Event theEvent) {
		String meSessionID = theEvent.getField("uid");
	}

	public void onListenAck(Event theEvent) {
		String meSessionID = theEvent.getField("uid");
	}

	/**
	 * @return pushletClient
	 */
//	public static  PushletClient getPushletClient() {
//		while(systemChatEngine.pushletClient==null){}
//		return systemChatEngine.pushletClient;
//	}

	/** Main program. */
//	public static void main(String args[]) {
//		systemChatEngine.start();
//	}

}

 

 

 

package com.jlee.im;

import java.util.HashMap;
import java.util.Map;

import sun.misc.BASE64Encoder;

public class WebIMClient {

	static SystemChatEngine engine = null ;
	
	public void sendTask()throws Exception{
		
		Map attributemap = new HashMap() ;
		BASE64Encoder encoder = new BASE64Encoder();
		String fromName = encoder.encode("jlee".getBytes("utf-8")) ;
		String message = java.net.URLEncoder.encode(
				encoder.encode(
						"baidu去百度查IM".getBytes("utf-8"))) ;
		String remark = encoder.encode("备注".getBytes("utf-8")) ;
		
		String title = encoder.encode("主题1".getBytes("utf-8")) ;
		String msgType = encoder.encode("类型1".getBytes("utf-8")) ;
		String msgGroup = encoder.encode("self".getBytes("utf-8")) ;//self(表示消息来自系统OA)或者other(消息来自其他系统)
		
		attributemap.put("uid" ,"728852348a9f4c219f9666facef19356") ;//该字段不会进入数据库,只是充当Pushlet所依赖的Id
		attributemap.put("fromId", "728852348a9f4c219f9666facef19356") ;
		attributemap.put("fromName", fromName) ;
		attributemap.put("toId", "86523b57993048a0b82bd06772e432dd") ;
		attributemap.put("toGroupId", null) ;
		attributemap.put("message", message) ;
		attributemap.put("remark", remark) ;

		attributemap.put("title", title) ;
		attributemap.put("msgType", msgType) ;
		attributemap.put("msgGroup", msgGroup) ;
		
		engine = SystemChatEngine.getInstance(
				"http://localhost:8888/im/pushlet.srv", "/pushlet/ping,/task/warn","/task/warn", attributemap) ;
		
	}
	
	public static void main(String[] args) {
		WebIMClient client = new WebIMClient() ;
		try {
			client.sendTask() ;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

 

  • bsIM.rar (5.8 MB)
  • 下载次数: 1188
  • pushlet实现webQQ即时通信_第14张图片
  • 大小: 24.5 KB
  • pushlet实现webQQ即时通信_第15张图片
  • 大小: 21.4 KB
  • pushlet实现webQQ即时通信_第16张图片
  • 大小: 9.3 KB
  • pushlet实现webQQ即时通信_第17张图片
  • 大小: 36.7 KB
  • pushlet实现webQQ即时通信_第18张图片
  • 大小: 36.8 KB
  • pushlet实现webQQ即时通信_第19张图片
  • 大小: 37.7 KB
  • pushlet实现webQQ即时通信_第20张图片
  • 大小: 9.4 KB
  • pushlet实现webQQ即时通信_第21张图片
  • 大小: 10.5 KB
  • pushlet实现webQQ即时通信_第22张图片
  • 大小: 30.9 KB
  • pushlet实现webQQ即时通信_第23张图片
  • 大小: 25.1 KB
  • pushlet实现webQQ即时通信_第24张图片
  • 大小: 8.7 KB
  • pushlet实现webQQ即时通信_第25张图片
  • 大小: 24.5 KB
  • pushlet实现webQQ即时通信_第26张图片
  • 大小: 19 KB
  • 查看图片附件

你可能感兴趣的:(Pushlet,webQQ,comet,服务器推,即时通信)