本文整理汇总了Java中me.chanjar.weixin.mp.api.WxMpMessageRouter类的典型用法代码示例。如果您正苦于以下问题:Java WxMpMessageRouter类的具体用法?Java WxMpMessageRouter怎么用?Java WxMpMessageRouter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WxMpMessageRouter类属于me.chanjar.weixin.mp.api包,在下文中一共展示了WxMpMessageRouter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: text
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
/**
* @param wxMpMessageRouter 微信路由
* @param async
* @param ask
* @param answer
*/
public static void text(
WxMpMessageRouter wxMpMessageRouter,
boolean async,
String ask,
String answer
) {
WxMpMessageHandler handler = (wxMessage, context, wxMpService, sessionManager) -> {
WxMpXmlOutTextMessage m
= WxMpXmlOutMessage
.TEXT()
.content(answer)
.fromUser(wxMessage.getToUserName())
.toUser(wxMessage.getFromUserName())
.build();
return m;
};
wxMpMessageRouter
.rule()
.async(async)
.content(ask)
.handler(handler)
.end();
}
开发者ID:cyzaoj,项目名称:mywx,代码行数:30,代码来源:WxMpUtil.java
示例2: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
private static void initWeixin() {
try (InputStream is1 = ClassLoader
.getSystemResourceAsStream("test-config.xml")) {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:28,代码来源:WxMpDemoServer.java
示例3: router
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
@Bean
public WxMpMessageRouter router(WxMpService wxMpService) {
final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
// 记录所有事件的日志 (异步执行)
// newRouter.rule().handler(this.logHandler).next();
// 自定义菜单事件
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT)
.event(WxConsts.BUTTON_CLICK).handler(this.menuHandler).end();
// 点击菜单连接事件
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT)
.event(WxConsts.BUTTON_VIEW).handler(this.nullHandler).end();
// 关注事件
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT)
.event(WxConsts.EVT_SUBSCRIBE).handler(this.subscribeHandler)
.end();
// 取消关注事件
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT)
.event(WxConsts.EVT_UNSUBSCRIBE)
.handler(this.unsubscribeHandler).end();
// 上报地理位置事件
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT)
.event(WxConsts.EVT_LOCATION).handler(this.locationHandler)
.end();
// 默认
newRouter.rule().async(false).handler(this.msgHandler).end();
return newRouter;
}
开发者ID:xjtushilei,项目名称:knowledge-forest-dialogue-recommendation,代码行数:38,代码来源:WechatMpConfiguration.java
示例4: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
private static void initWeixin() {
try (InputStream is1 = ClassLoader
.getSystemResourceAsStream("test-config.xml")) {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceApacheHttpClientImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:binarywang,项目名称:weixin-java-tools,代码行数:28,代码来源:WxMpDemoServer.java
示例5: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
private static void initWeixin() {
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
try {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} finally {
IOUtils.closeQuietly(is1);
}
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:28,代码来源:WxMpDemoServer.java
示例6: WxMpEndpointServlet
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
public WxMpEndpointServlet(WxMpConfigStorage wxMpConfigStorage, WxMpService wxMpService,
WxMpMessageRouter wxMpMessageRouter) {
this.wxMpConfigStorage = wxMpConfigStorage;
this.wxMpService = wxMpService;
this.wxMpMessageRouter = wxMpMessageRouter;
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:7,代码来源:WxMpEndpointServlet.java
示例7: WxMpEndpointServlet
import me.chanjar.weixin.mp.api.WxMpMessageRouter; //导入依赖的package包/类
public WxMpEndpointServlet(WxMpConfigStorage wxMpConfigStorage, WxMpService wxMpService,
WxMpMessageRouter wxMpMessageRouter) {
this.wxMpConfigStorage = wxMpConfigStorage;
this.wxMpService = wxMpService;
this.wxMpMessageRouter = wxMpMessageRouter;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:WxMpEndpointServlet.java
注:本文中的me.chanjar.weixin.mp.api.WxMpMessageRouter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论