本文整理汇总了Java中org.grain.threadmsg.ThreadMsgManager.dispatchThreadMsg方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadMsgManager.dispatchThreadMsg方法的具体用法?Java ThreadMsgManager.dispatchThreadMsg怎么用?Java ThreadMsgManager.dispatchThreadMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.grain.threadmsg.ThreadMsgManager
的用法示例。
在下文中一共展示了ThreadMsgManager.dispatchThreadMsg方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageReceived
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
super.messageReceived(session, message);
if (MinaConfig.log != null) {
MinaConfig.log.info("minaserver messageReceived");
}
TcpPacket pt = (TcpPacket) message;
// 如果是获取锁,需要汇集到一个线程
if (pt.gettOpCode() == DistributedlockTCode.DISTRIBUTED_LOCK_C1) {
ThreadMsgManager.dispatchThreadMsg(DistributedlockMsg.MERGE_TCPPACKET, message, null);
} else {
// 其他情况不需要
ThreadTcpManager.dispatchTcp(pt);
}
}
示例2: onRemove
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void onRemove() throws Exception {
// 离开场景时xxx
// 发布离线消息
UserOffline.Builder builder = UserOffline.newBuilder();
builder.setUserId(getUserId());
ThreadMsgManager.dispatchThreadMsg(MsgOpCodeChat.USER_OFFLINE, builder.build(), this);
}
示例3: onOpen
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@OnOpen
public void onOpen(Session session) {
try {
ThreadMsgManager.dispatchThreadMsg(WSMsg.WEBSOCKET_CLIENT_CREATE_CONNECT, null, session);
} catch (Exception e) {
if (WSManager.log != null) {
WSManager.log.error("MsgManager.dispatchMsg error", e);
}
}
}
示例4: onClose
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@OnClose
public void onClose(Session session, CloseReason closeReason) {
try {
ThreadMsgManager.dispatchThreadMsg(WSMsg.WEBSOCKET_CLIENT_DISCONNECT, null, session);
} catch (Exception e) {
if (WSManager.log != null) {
WSManager.log.error("MsgManager.dispatchMsg error", e);
}
}
}
示例5: sessionClosed
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void sessionClosed(IoSession session) throws Exception {
super.sessionClosed(session);
if (MinaConfig.log != null) {
MinaConfig.log.warn("minaserver sessionClosed");
}
ThreadMsgManager.dispatchThreadMsg(TcpMsg.MINA_CLIENT_DISCONNECT, null, session);
}
示例6: sessionCreated
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void sessionCreated(IoSession session) throws Exception {
super.sessionCreated(session);
if (MinaConfig.log != null) {
MinaConfig.log.info("minaserver sessionCreated");
}
ThreadMsgManager.dispatchThreadMsg(TcpMsg.MINA_CLIENT_CREATE_CONNECT, null, session);
}
示例7: sessionClosed
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void sessionClosed(IoSession session) throws Exception {
super.sessionClosed(session);
if (MinaConfig.log != null) {
MinaConfig.log.warn("minaclient sessionClosed");
}
// 设置链接已断开,断线过会儿会断线重连
MinaClient.getInstance().ioConnectorStateMap.put(ioConnector, false);
// 发布与服务器断开的消息
ThreadMsgManager.dispatchThreadMsg(TcpMsg.MINA_SERVER_DISCONNECT, this.name, session);
}
示例8: sessionCreated
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
@Override
public void sessionCreated(IoSession session) throws Exception {
super.sessionCreated(session);
if (MinaConfig.log != null) {
MinaConfig.log.info("minaclient sessionCreated");
}
// 发布与服务器链接成功的消息
ThreadMsgManager.dispatchThreadMsg(TcpMsg.MINA_SERVER_CONNECTED, this.name, session);
}
示例9: minaServerConnected
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的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);
}
示例10: onDistributedlockCanUse
import org.grain.threadmsg.ThreadMsgManager; //导入方法依赖的package包/类
public void onDistributedlockCanUse(MsgPacket msgPacket) {
// 发布四条消息,分配至随机线程,不同类型互补影响,相同类型不同键值互不影响
ThreadMsgManager.dispatchThreadMsg("DISTRIBUTEDLOCK_TEST", null, null);
ThreadMsgManager.dispatchThreadMsg("DISTRIBUTEDLOCK_TEST", null, null);
ThreadMsgManager.dispatchThreadMsg("DISTRIBUTEDLOCK_TEST1", null, null);
ThreadMsgManager.dispatchThreadMsg("DISTRIBUTEDLOCK_TEST1", null, null);
}