本文整理汇总了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);
}
示例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();
}
示例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("该链接未登陆,不用走下线流程或者是主动下线");
}
}
示例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();
}
示例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("该链接未登陆,不用走下线流程或者是主动下线");
}
}
示例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);
}
示例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());
}
示例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);
}