From 4237f13f8aa103c5f7e09e90147cb4c0b67c6df8 Mon Sep 17 00:00:00 2001 From: hongjun117 <380386614@qq.com> Date: Wed, 1 Nov 2017 10:10:25 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试一下 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01d82c1..a7f74dc 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,6 @@ mpush allocator demo > > content-type : text/plain;charset=utf-8 -### 其他 +### 其他 123456 From f48456492af0dd531a2aa47b4a194ffea44b804a Mon Sep 17 00:00:00 2001 From: tuantuanyu Date: Wed, 1 Nov 2017 10:25:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改动 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7f74dc..d392cc2 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,4 @@ mpush allocator demo ### 其他 123456 - +####改动 From d012b9a5399e144310ae0c355794c74f603e45af Mon Sep 17 00:00:00 2001 From: yyj Date: Wed, 1 Nov 2017 12:10:14 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=B7=9F=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/shinemo/mpush/alloc/PushHandler.java | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/shinemo/mpush/alloc/PushHandler.java b/src/main/java/com/shinemo/mpush/alloc/PushHandler.java index 7e2dee7..3148eb1 100644 --- a/src/main/java/com/shinemo/mpush/alloc/PushHandler.java +++ b/src/main/java/com/shinemo/mpush/alloc/PushHandler.java @@ -21,10 +21,12 @@ import com.mpush.api.Constants; import com.mpush.api.push.*; +import com.mpush.common.druid.MysqlConnecter; import com.mpush.tools.Jsons; import com.mpush.tools.common.Strings; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +47,7 @@ private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final PushSender pushSender = PushSender.create(); private final AtomicInteger idSeq = new AtomicInteger(); + String message = null; public void start() { pushSender.start(); @@ -62,7 +65,7 @@ public void handle(HttpExchange httpExchange) throws IOException { sendPush(params); - byte[] data = "服务已经开始推送,请注意查收消息".getBytes(Constants.UTF_8); + byte[] data = message.getBytes(Constants.UTF_8); httpExchange.getResponseHeaders().set("Content-Type", "text/plain; charset=utf-8"); httpExchange.sendResponseHeaders(200, data.length);//200, content-length OutputStream out = httpExchange.getResponseBody(); @@ -77,27 +80,38 @@ private void sendPush(Map params) { Boolean broadcast = (Boolean) params.get("broadcast"); String condition = (String) params.get("condition"); + //验证用户在数据库中是否存在 + MysqlConnecter mc = new MysqlConnecter(); + String mobile = mc.selectOne("select mobile from m_user where device_id='"+userId+"'"); + System.out.println("-----绑定用户在数据库--------"+mobile); + if (StringUtils.isBlank(mobile)){ + message = "绑定用户在数据库中不存在:userId="+userId; + }else { + NotificationDO notificationDO = new NotificationDO(); + //notificationDO.content = "MPush开源推送," + hello; + notificationDO.content = hello; + //notificationDO.title = "消息推送"; + //notificationDO.nid = idSeq.get() % 2 + 1; + //notificationDO.ticker = "你有一条新的消息,请注意查收"; + System.out.println("json内容:"+Jsons.toJson(notificationDO)); + PushMsg pushMsg = PushMsg.build(MsgType.NOTIFICATION_AND_MESSAGE, Jsons.toJson(notificationDO)); + pushMsg.setMsgId("msg_" + idSeq.incrementAndGet()); + + pushSender.send(PushContext + .build(pushMsg) + .setUserId(Strings.isBlank(userId) ? null : userId) + .setBroadcast(broadcast != null && broadcast) + .setCondition(Strings.isBlank(condition) ? null : condition) + .setCallback(new PushCallback() { + @Override + public void onResult(PushResult result) { + logger.info(result.toString()); + } + }) + ); + message = "服务已经开始推送,请注意查收消息"; + } - NotificationDO notificationDO = new NotificationDO(); - notificationDO.content = "MPush开源推送," + hello; - notificationDO.title = "MPUSH推送"; - notificationDO.nid = idSeq.get() % 2 + 1; - notificationDO.ticker = "你有一条新的消息,请注意查收"; - PushMsg pushMsg = PushMsg.build(MsgType.NOTIFICATION_AND_MESSAGE, Jsons.toJson(notificationDO)); - pushMsg.setMsgId("msg_" + idSeq.incrementAndGet()); - - pushSender.send(PushContext - .build(pushMsg) - .setUserId(Strings.isBlank(userId) ? null : userId) - .setBroadcast(broadcast != null && broadcast) - .setCondition(Strings.isBlank(condition) ? null : condition) - .setCallback(new PushCallback() { - @Override - public void onResult(PushResult result) { - logger.info(result.toString()); - } - }) - ); } private byte[] readBody(HttpExchange httpExchange) throws IOException { From a4ac5c6934abb2caead84e48498a4f8697f22a75 Mon Sep 17 00:00:00 2001 From: hongjun117 <380386614@qq.com> Date: Thu, 2 Nov 2017 13:50:53 +0800 Subject: [PATCH 4/6] 123456789 123456789 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7f74dc..f060ed3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,6 @@ mpush allocator demo > > content-type : text/plain;charset=utf-8 -### 其他 123456 +### 其他 123456789 From 8d94d0d7f66f027087b0474acabd08cf7a0a475d Mon Sep 17 00:00:00 2001 From: yyj Date: Thu, 2 Nov 2017 17:46:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ef0fb5..3917526 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ mpush allocator demo > > content-type : text/plain;charset=utf-8 -### 其他 123456789 +### 打包部署 +alloc打包方法 +进入master目录 运行命令:mvn install(或者将mpush-client-0.8.0.jar手动放入alloc的jar文件夹下) +进入alloc目录,运行命令 +mvn clean package -Pzip,pub + -####改动 From ff29f47d589e49a38562b583b6e4fcfe662a8812 Mon Sep 17 00:00:00 2001 From: yyj Date: Mon, 6 Nov 2017 10:21:10 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/shinemo/mpush/alloc/PushHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/shinemo/mpush/alloc/PushHandler.java b/src/main/java/com/shinemo/mpush/alloc/PushHandler.java index 3148eb1..e8b9f2e 100644 --- a/src/main/java/com/shinemo/mpush/alloc/PushHandler.java +++ b/src/main/java/com/shinemo/mpush/alloc/PushHandler.java @@ -21,10 +21,10 @@ import com.mpush.api.Constants; import com.mpush.api.push.*; -import com.mpush.common.druid.MysqlConnecter; import com.mpush.tools.Jsons; import com.mpush.tools.common.Strings; import com.sun.net.httpserver.HttpExchange; +import com.mpush.common.druid.MysqlConnecter; import com.sun.net.httpserver.HttpHandler; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger;