亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? msgsenderthread.java

?? java的一個(gè)Socket通信實(shí)現(xiàn)
?? JAVA
字號:
package com.gsoft.workflow.msgsender;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Hashtable;

import com.gsoft.workflow.msgsender.Tokens;
import com.lotus.sametime.awareness.AwarenessService;
import com.lotus.sametime.awareness.StatusEvent;
import com.lotus.sametime.awareness.StatusListener;
import com.lotus.sametime.awareness.WatchList;
import com.lotus.sametime.community.CommunityService;
import com.lotus.sametime.community.Login;
import com.lotus.sametime.community.LoginEvent;
import com.lotus.sametime.community.LoginListener;
import com.lotus.sametime.community.ServerAppService;
import com.lotus.sametime.community.ServiceEvent;
import com.lotus.sametime.community.ServiceListener;
import com.lotus.sametime.core.comparch.DuplicateObjectException;
import com.lotus.sametime.core.comparch.STSession;
import com.lotus.sametime.core.constants.EncLevel;
import com.lotus.sametime.core.constants.ImTypes;
import com.lotus.sametime.core.types.STUser;
import com.lotus.sametime.core.types.STUserInstance;
import com.lotus.sametime.core.util.connection.Connection;
import com.lotus.sametime.core.util.connection.SocketConnection;
import com.lotus.sametime.im.Im;
import com.lotus.sametime.im.ImEvent;
import com.lotus.sametime.im.ImListener;
import com.lotus.sametime.im.ImServiceListener;
import com.lotus.sametime.im.InstantMessagingService;
import com.lotus.sametime.lookup.LookupService;
import com.lotus.sametime.lookup.ResolveEvent;
import com.lotus.sametime.lookup.ResolveListener;
import com.lotus.sametime.lookup.Resolver;
import com.lotus.sametime.token.SATokenService;
import com.lotus.sametime.token.Token;
import com.lotus.sametime.token.TokenEvent;
import com.lotus.sametime.token.TokenServiceListener;

public class MsgSenderThread implements Runnable, LoginListener, ServiceListener,  
								ImServiceListener, ImListener,ResolveListener, 
								StatusListener,TokenServiceListener{
	String welcomeMessage = "Welcome to the GroupChatBot.";
	
	protected static boolean debug = true;
	protected boolean running = true;
	protected static String USERTOALERT = "<utw>";
	protected static final String STDRESPONSE = "I\'m sorry.  I don\'t take messages from users";
	protected static final String STATUSMSG = "The Alert Bot is online!";
	
	protected Thread engine;
	protected Token token;
	protected Tokens m_tokens = new Tokens();
	protected SATokenService tokenService;
	protected STSession session;
	protected ServerAppService m_saService;
	protected CommunityService service;
	protected InstantMessagingService imService;
	protected Login login;
	protected LookupService lookupService;
	protected Resolver resolver;
	protected AwarenessService awarenessService;
	protected WatchList watchList;
	protected Im im;
	protected STUser stuser;
	protected String userName;
	protected String sendTo;
	protected String text;
	public boolean isSent=false;
	
	private Hashtable unSentMsg = new Hashtable();
	
	public MsgSenderThread() throws DuplicateObjectException {
			session= new STSession("WebOA12");            
			session.loadSemanticComponents();
			session.start();
			loadComponents();
	}
  
	public void start(String server, String username, String password)
	{
	
		service = (CommunityService)session.getCompApi(CommunityService.COMP_NAME);
		m_saService = (ServerAppService)session.getCompApi(ServerAppService.COMP_NAME);
		service.addServiceListener(this);
		login(server, username, password);
		
		//init Token new
		m_tokens.initSametime(server);
		
	}
  
	public void stop()
	{	
		service.logout();
	}

	public void loggedIn(LoginEvent arg0) {
		
		
		//Register to listen for incoming messages
		imService = (InstantMessagingService) session.getCompApi(InstantMessagingService.COMP_NAME);
		imService.registerImType(ImTypes.IM_TYPE_CHAT);
		imService.addImServiceListener(this);

		//Get a handle to the Lookup Service and add a resolve listener
		lookupService = (LookupService) session.getCompApi(LookupService.COMP_NAME);
		resolver = lookupService.createResolver(false, false, true, false);
		resolver.addResolveListener(this);

		//Get a handle to the Awareness Service and create a WatchList
		awarenessService = (AwarenessService) session.getCompApi(AwarenessService.COMP_NAME);
		watchList = awarenessService.createWatchList();
		watchList.addStatusListener(this);
		
		//resolver.resolve(sendTo);

	}
	
	public boolean isLogged()  //判斷是否登錄成功
	{
		if(session !=null)
			return session.isActive();
		else
			return false;
	}
	
	public void callrevsolve(String sendTo,String sendtime,String msgcontent,String msgtype){
		this.sendTo=sendTo;
		this.text=msgcontent;
		isSent=false;
		resolver.resolve(sendTo);
		
	}

	public void loggedOut(LoginEvent arg0) {
		int reason = arg0.getReason();
	    if (reason == 0)
	    	printOut("Successfully logged out.");
	    else 
	    	printOut("Failed to login.  Return Code =" + reason);
	    session.stop();
	    session.unloadSession();
	}

	public void serviceAvailable(ServiceEvent arg0) {}

	public void imReceived(ImEvent arg0) {
		printOut("IM Received");

	}

	public void dataReceived(ImEvent arg0) {
		printOut("Data is Received!");
	}

	public void imClosed(ImEvent arg0) {
		printOut("IM Closed from " + arg0.getIm().getPartner().getName());
		im = null;
		arg0.getIm().removeImListener(this);	
	}

	public void imOpened(ImEvent arg0) {
		printOut("IM Opened to " + arg0.getIm().getPartner().getName());
		if (arg0.getIm().isOpen()) {
			String str = arg0.getIm().getPartner().getName();
			printOut("Message sent to " + str);
			if(im==null)
				im = arg0.getIm();
			sendMessage();
		}

		
	}

	public void openImFailed(ImEvent arg0) {
		isSent=true;
		printOut("Open IM Failed");
	}

	public void textReceived(ImEvent arg0) {
		printOut("Text is Received! " + arg0.getText()+" from " + arg0.getIm().getPartner().getName());
	}

	public void resolveConflict(ResolveEvent arg0) {}

	public void resolveFailed(ResolveEvent arg0) {}

	public void resolved(ResolveEvent arg0) {
		
		if (arg0.getResolved() instanceof STUser) {
			STUser user = ((STUser) arg0.getResolved());
			//tokenService.generateToken(user);
			String userName = user.getName();
			printOut("Resolved " + userName);
			watchList.addItem(user);
			printOut("Added " + userName + " to WatchList");
			this.userName =userName; 
			
			//Generate Token String new
			m_tokens.generateToken(user);
			while(m_tokens.getToken()==null){
				try{
					Thread.sleep(100);
				}catch(Exception e){
					
				}
			}
			
			//Add Token String into message new
			String str = "";
			String tmp = text.toLowerCase();
			int begin = tmp.indexOf("<a");
			
			if(begin >= 0){
				Configuration rc = new Configuration("st.property");
				if(begin>1)str = tmp.substring(1, begin);
				begin = tmp.indexOf("=", begin);
				str = str + "<a href='http://"+rc.getValue("domain")+"/servlet/SSORedirect?LtpaToken="+m_tokens.getToken().getTokenString();
				str = str + "&RedirectTo=" + tmp.substring(begin+1);
				text=str;	
			}
			
			
			//Send message new
			if(im==null){
				stuser = user;
				im = imService.createIm(stuser, EncLevel.ENC_LEVEL_NONE, ImTypes.IM_TYPE_CHAT);
				im.addImListener(this);
				im.open();
			}else
			{
				sendMessage();
			}

		}
	}
	
	private void loadComponents() {
		String[] compNames = { "com.lotus.sametime.community.STBase",
				"com.lotus.sametime.token.SATokenComp" };

		session.loadComponents(compNames);

	}

	void loginToServer(String serverName) {
		m_saService.addLoginListener(this);
		
		short loginType = STUserInstance.LT_SERVER_APP;

		Connection[] connections = { new SocketConnection(8082, 17000)};
		m_saService.setConnectivity(connections);	
		m_saService.loginAsServerApp(serverName, loginType, "SametimeServlet",null);
	}

	public void groupCleared(StatusEvent arg0) {}

	private void login(String server, String username, String password)
	{
		service.addLoginListener(this); 
		service.loginByPassword(server,username, password);
	}
	
	public void run() {
		Thread myThread = Thread.currentThread();
		while (running) {
			try {
				Thread.sleep(1000);
			}
			catch (InterruptedException e) {
			}
		}

	}
	
	public void destroy() {
		if (service != null && service.isLoggedIn()) {
			try {
				service.logout();
				running = false;
				engine.interrupt();
			}
			catch (Exception exc) {
				printOut("Could not logout: " + exc.toString());
			}
		}
	}
	
	protected boolean sendMessage(){
		//if(stuser != null){
		
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream dataStream = new DataOutputStream(baos);
			try
		    {
		        dataStream.writeUTF("data");
		        dataStream.writeUTF("richtext");
		        dataStream.write(new byte[] {-18});
		    }
		    catch(IOException e)
		    {
		        return false;
		    	//throw new AssertionError("sendDataMessage failed");
		        
		    }
		    
		    im.sendData(true, 27191, 0, baos.toByteArray());
		    String str =text;
		    im.sendText(true, str);
		    isSent=true;
		    //im.sendText(true, "hhhhhhhh");
		    printOut("Sent '"+text+"' to "+im.getPartner().getName());
		    
		    return true;
		//}
		//return false;
	}
	
		
	private void printOut(String str){
		if(debug==true)System.out.println(str);
	}

	public void userStatusChanged(StatusEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void generateTokenFailed(TokenEvent arg0) {
		// TODO Auto-generated method stub
		System.err.println(arg0.toString());
	}

	public void serviceAvailable(TokenEvent arg0) {
		// TODO Auto-generated method stub
		System.err.println(arg0.toString());
		
	}

	public void tokenGenerated(TokenEvent arg0) {
		// TODO Auto-generated method stub
		token = arg0.getToken();
		System.err.println(token.getTokenString());
		//isSent = true;
		
	}

	public void setIm(Im im) {
		this.im = im;
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费观看高清完整版在线观看 | 成人性生交大片免费| 成人综合在线网站| 欧美日韩成人一区| 国产日产精品一区| 久久黄色级2电影| 欧美日韩一区二区三区在线看| 午夜久久福利影院| 丁香婷婷综合色啪| 91精品国产手机| 亚洲图片欧美视频| 成人免费精品视频| 精品久久久久av影院| 天天综合色天天| 色综合久久综合网97色综合| 国产午夜亚洲精品羞羞网站| 日韩影院免费视频| 欧美色视频在线观看| 亚洲欧美在线观看| 成人福利视频在线看| 国产亚洲精品中文字幕| 久久精品国产77777蜜臀| 777亚洲妇女| 亚洲国产精品自拍| 91视频精品在这里| 亚洲欧洲三级电影| 99热国产精品| 国产精品久久久久久妇女6080| 久久精工是国产品牌吗| 日韩免费观看高清完整版在线观看| 亚洲一区免费在线观看| 一本久道中文字幕精品亚洲嫩| 国产日韩高清在线| 国产大片一区二区| 2020国产精品久久精品美国| 日本欧美加勒比视频| 91麻豆精品久久久久蜜臀| 成人小视频免费在线观看| 亚洲精品在线免费观看视频| 久久成人羞羞网站| 久久综合狠狠综合久久综合88 | 欧美极品aⅴ影院| 国产成人免费视频网站高清观看视频| 2020国产精品自拍| 国产iv一区二区三区| 欧美高清在线精品一区| 91在线看国产| 一区二区免费视频| 欧美日韩国产不卡| 久久精品国产99久久6| 精品国产伦一区二区三区免费| 国产一区二区三区在线观看免费| 久久综合色之久久综合| aaa亚洲精品| 一区二区三区在线观看网站| 宅男噜噜噜66一区二区66| 久色婷婷小香蕉久久| 国产欧美日韩一区二区三区在线观看| 91精品国产福利在线观看| 精品一区二区在线看| 国产夫妻精品视频| 国产在线观看免费一区| 国产v综合v亚洲欧| 色综合天天综合网天天狠天天 | 一本色道a无线码一区v| 成人精品一区二区三区四区| 久久国产日韩欧美精品| 成人午夜免费电影| 欧美日韩高清在线| 成人免费小视频| 欧美aaaaaa午夜精品| av一区二区三区在线| 欧美日本精品一区二区三区| 欧美成人高清电影在线| 精品一区中文字幕| 欧美精品v日韩精品v韩国精品v| 欧美一区二区高清| 波多野结衣在线aⅴ中文字幕不卡| 日韩色视频在线观看| 国产在线精品视频| 美女网站色91| 久久久综合视频| 亚洲日本在线视频观看| 一区二区三区在线免费视频 | 国产成人一区二区精品非洲| 免费观看一级特黄欧美大片| 2014亚洲片线观看视频免费| 高清久久久久久| 亚洲综合激情网| 一区二区三区在线播| 日韩一二三四区| 欧美在线视频日韩| 不卡的av在线播放| 久久99精品久久久久久| 亚洲在线观看免费| 国产精品免费视频网站| 欧美大胆人体bbbb| 欧美三区在线观看| 97久久精品人人做人人爽| 国产在线播精品第三| 日韩国产精品久久久| 亚洲大片在线观看| 一区二区三区免费网站| 欧美久久久久久久久| 成人一区二区三区在线观看| 国产欧美日韩在线| 欧美体内she精视频| 日韩极品在线观看| 一区二区三区不卡在线观看| 欧美日韩国产首页| 国产丶欧美丶日本不卡视频| 中文字幕在线不卡视频| 欧美日韩视频不卡| 国产乱码一区二区三区| 国产精品国产三级国产三级人妇 | 美女一区二区三区在线观看| 日韩欧美高清dvd碟片| 粉嫩av亚洲一区二区图片| 国产自产高清不卡| 亚洲老妇xxxxxx| 亚洲成人福利片| 日韩精品一二三| 国产精品1区2区3区| 欧美日韩一区二区电影| 欧美性一区二区| 午夜精品久久久久久久99水蜜桃| 日韩欧美区一区二| 欧美色图片你懂的| 高清不卡一区二区在线| 欧美日本一道本| 久久国产免费看| 亚洲国产精品嫩草影院| 欧美精品1区2区3区| 91精品国产一区二区三区香蕉 | 国产精品动漫网站| 自拍视频在线观看一区二区| 亚洲黄色尤物视频| 五月天网站亚洲| 日本午夜一区二区| 精品一区二区三区影院在线午夜 | 欧美精品一区二区蜜臀亚洲| 精品国产网站在线观看| 国产拍欧美日韩视频二区| 国产欧美日韩不卡| 一区二区三区四区精品在线视频| 亚洲影视资源网| 韩国成人在线视频| 不卡的av中国片| 欧美电影在线免费观看| 久久久另类综合| 亚洲三级在线免费观看| 首页国产丝袜综合| 国产一区二区三区电影在线观看 | 国产精品初高中害羞小美女文| 夜夜精品视频一区二区 | 日韩欧美一二三| 亚洲国产精品成人综合色在线婷婷| 一色桃子久久精品亚洲| 视频一区二区中文字幕| 成人免费高清视频| 日韩一区二区视频在线观看| 国产精品免费av| 日本特黄久久久高潮| 97se亚洲国产综合在线| 91精品国产综合久久福利| 综合久久久久综合| 久久97超碰国产精品超碰| 在线观看亚洲专区| 国产日本欧美一区二区| 日本中文字幕一区| 91年精品国产| 久久久久国产精品麻豆| 爽好久久久欧美精品| 99久久婷婷国产精品综合| 久久亚洲综合色| 亚洲韩国精品一区| 不卡影院免费观看| 精品国产乱码久久久久久老虎 | 欧美亚洲综合在线| 国产精品污网站| 国产一区 二区 三区一级| 欧美顶级少妇做爰| 亚洲一区二区三区视频在线播放| 豆国产96在线|亚洲| 久久久噜噜噜久噜久久综合| 免费人成精品欧美精品| 欧美日韩国产欧美日美国产精品| 亚洲免费观看高清在线观看| 国产精品一区二区在线观看不卡 | 久久99国产精品成人| 欧美一区二区在线播放| 亚洲国产乱码最新视频| 色吊一区二区三区| 国产拍欧美日韩视频二区| 国产伦理精品不卡| 久久免费电影网| 国产一区二三区| 久久久亚洲欧洲日产国码αv| 97久久超碰国产精品电影| 中文幕一区二区三区久久蜜桃|