當前位置: 首頁>>代碼示例>>Java>>正文


Java MsgPacket.getOtherData方法代碼示例

本文整理匯總了Java中org.grain.msg.MsgPacket.getOtherData方法的典型用法代碼示例。如果您正苦於以下問題:Java MsgPacket.getOtherData方法的具體用法?Java MsgPacket.getOtherData怎麽用?Java MsgPacket.getOtherData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.grain.msg.MsgPacket的用法示例。


在下文中一共展示了MsgPacket.getOtherData方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onServerConnected

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
public void onServerConnected(MsgPacket msgPacket) {
	IoSession session = (IoSession) msgPacket.getOtherData();
	System.out.println("接到消息:" + msgPacket.getMsgOpCode());
	RPCTestC.Builder builder = RPCTestC.newBuilder();
	builder.setName("RPC你好啊");
	TcpPacket pt = new TcpPacket(TestTCode.TEST_RPC_C, builder.build());

	TcpPacket ptReturn = WaitLockManager.lock(session, pt);
	RPCTestS rpcTestS = (RPCTestS) ptReturn.getData();
	System.out.println("接到RPC消息:" + rpcTestS.getName());

	RPCTestC.Builder builder1 = RPCTestC.newBuilder();
	builder1.setName("TCP你好啊");
	TcpPacket pt1 = new TcpPacket(TestTCode.TEST_RPC_C, builder1.build());
	session.write(pt1);

}
 
開發者ID:dianbaer,項目名稱:grain,代碼行數:18,代碼來源:TestMsgService.java

示例2: userOfflineHandle

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
/**
 * 線程1的業務
 * 
 * @param msgPacket
 */
public void userOfflineHandle(MsgPacket msgPacket) {
	OnlineUser onlineUser = (OnlineUser) msgPacket.getOtherData();
	List<UserData> friendList = null;
	if (!StringUtil.stringIsNull(onlineUser.getUserData().getUserGroupTopId())) {
		friendList = IdentityAction.getFriendList(onlineUser.getUserData().getUserGroupTopId(), onlineUser.getToken());
		if (friendList != null && friendList.size() != 0) {
			ChatUserOfflineS.Builder chatUserOfflineSBuilder = ChatUserOfflineS.newBuilder();
			chatUserOfflineSBuilder.setWsOpCode(WsOpCodeChat.USER_OFFLINE_S);
			chatUserOfflineSBuilder.setUserId(onlineUser.getUserId());
			WsPacket sendOfflineWsPacket = new WsPacket(WsOpCodeChat.USER_OFFLINE_S, chatUserOfflineSBuilder.build());
			// 廣播給在線好友上線
			for (int i = 0; i < friendList.size(); i++) {
				UserData friendUserData = friendList.get(i);
				if (friendUserData.getUserId().equals(onlineUser.getUserId())) {
					// 排除自己
					continue;
				}
				OnlineUser friendOnlineUser = OnlineUserManager.getOnlineUserByUserId(friendUserData.getUserId());
				if (friendOnlineUser == null) {
					continue;
				}
				friendOnlineUser.send(sendOfflineWsPacket);
			}
		}
	}
	OnlineUserManager.removeOnlineUser(onlineUser);
	onlineUser.clear();
}
 
開發者ID:dianbaer,項目名稱:anychat,代碼行數:34,代碼來源:LoginChatService.java

示例3: webSocketCientDisConnectHandle

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
/**
 * 線程1的業務
 * 
 * @param msgPacket
 */
public void webSocketCientDisConnectHandle(MsgPacket msgPacket) {
	Session session = (Session) msgPacket.getOtherData();
	OnlineUser onlineUser = OnlineUserManager.getOnlineUserBySessionId(session.getId());
	if (onlineUser != null) {
		onlineUser.setDisConnect(true);
	} else {
		WSManager.log.info("該鏈接未登陸,不用走下線流程或者是主動下線");
	}
}
 
開發者ID:dianbaer,項目名稱:anychat,代碼行數:15,代碼來源:LoginChatService.java

示例4: userOfflineHandle

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
/**
 * 線程1的業務
 * 
 * @param msgPacket
 */
public void userOfflineHandle(MsgPacket msgPacket) {
	OnlineUserMongodb onlineUser = (OnlineUserMongodb) msgPacket.getOtherData();
	List<UserData> friendList = null;
	if (!StringUtil.stringIsNull(onlineUser.getUserData().getUserGroupTopId())) {
		friendList = IdentityAction.getFriendList(onlineUser.getUserData().getUserGroupTopId(), onlineUser.getToken());
		if (friendList != null && friendList.size() != 0) {
			ChatUserOfflineS.Builder chatUserOfflineSBuilder = ChatUserOfflineS.newBuilder();
			chatUserOfflineSBuilder.setWsOpCode(WsOpCodeChat.USER_OFFLINE_S);
			chatUserOfflineSBuilder.setUserId(onlineUser.getUserId());
			WsPacket sendOfflineWsPacket = new WsPacket(WsOpCodeChat.USER_OFFLINE_S, chatUserOfflineSBuilder.build());
			// 廣播給在線好友上線
			for (int i = 0; i < friendList.size(); i++) {
				UserData friendUserData = friendList.get(i);
				if (friendUserData.getUserId().equals(onlineUser.getUserId())) {
					// 排除自己
					continue;
				}
				OnlineUserMongodb friendOnlineUser = OnlineUserManagerMongodb.getOnlineUserByUserId(friendUserData.getUserId());
				if (friendOnlineUser == null) {
					continue;
				}
				friendOnlineUser.send(sendOfflineWsPacket);
			}
		}
	}
	OnlineUserManagerMongodb.removeOnlineUser(onlineUser);
	onlineUser.clear();
}
 
開發者ID:dianbaer,項目名稱:anychat,代碼行數:34,代碼來源:LoginChatServiceMongodb.java

示例5: webSocketCientDisConnectHandle

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
/**
 * 線程1的業務
 * 
 * @param msgPacket
 */
public void webSocketCientDisConnectHandle(MsgPacket msgPacket) {
	Session session = (Session) msgPacket.getOtherData();
	OnlineUserMongodb onlineUser = OnlineUserManagerMongodb.getOnlineUserBySessionId(session.getId());
	if (onlineUser != null) {
		onlineUser.setDisConnect(true);
	} else {
		WSManager.log.info("該鏈接未登陸,不用走下線流程或者是主動下線");
	}
}
 
開發者ID:dianbaer,項目名稱:anychat,代碼行數:15,代碼來源:LoginChatServiceMongodb.java

示例6: onServerConnected

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
public void onServerConnected(MsgPacket msgPacket) {
	IoSession session = (IoSession) msgPacket.getOtherData();
	System.out.println("接到消息:" + msgPacket.getMsgOpCode());
	TestC.Builder builder = TestC.newBuilder();
	builder.setName("你好啊");
	TcpPacket pt = new TcpPacket(TestTCode.TESTC, builder.build());
	session.write(pt);
}
 
開發者ID:dianbaer,項目名稱:grain,代碼行數:9,代碼來源:TestMsgService.java

示例7: onClientConnected

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
public void onClientConnected(MsgPacket msgPacket) {
	IoSession session = (IoSession) msgPacket.getOtherData();
	System.out.println("接到消息:" + msgPacket.getMsgOpCode());
	RPCTestS.Builder builder = RPCTestS.newBuilder();
	builder.setName("RPC你好啊");
	TcpPacket pt = new TcpPacket(TestTCode.TEST_RPC_SERVER, builder.build());

	TcpPacket ptReturn = WaitLockManager.lock(session, pt);
	RPCTestC rpcTestC = (RPCTestC) ptReturn.getData();
	System.out.println("接到RPC消息:" + rpcTestC.getName());

}
 
開發者ID:dianbaer,項目名稱:grain,代碼行數:13,代碼來源:TestMsgService.java

示例8: minaServerConnected

import org.grain.msg.MsgPacket; //導入方法依賴的package包/類
/**
 * 通知叫name的鎖服務器可以使用了
 * 
 * @param msgPacket
 */
public void minaServerConnected(MsgPacket msgPacket) {
	IoSession ioSession = (IoSession) msgPacket.getOtherData();
	String name = (String) msgPacket.getData();
	ioSessionServerMap.put(name, ioSession);
	ThreadMsgManager.dispatchThreadMsg(DistributedlockMsg.DISTRIBUTEDLOCK_SERVER_CAN_USE, name, null);
}
 
開發者ID:dianbaer,項目名稱:grain,代碼行數:12,代碼來源:MinaClientService.java


注:本文中的org.grain.msg.MsgPacket.getOtherData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。