Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
夜色
committed
Dec 24, 2016
1 parent
e3cc21f
commit 317c786
Showing
31 changed files
with
1,488 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
mpush-api/src/main/java/com/mpush/api/spi/push/IPushMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* (C) Copyright 2015-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Contributors: | ||
* ohun@live.cn (夜色) | ||
*/ | ||
|
||
package com.mpush.api.spi.push; | ||
|
||
import com.mpush.api.common.Condition; | ||
|
||
/** | ||
* Created by ohun on 2016/12/24. | ||
* | ||
* @author ohun@live.cn (夜色) | ||
*/ | ||
public interface IPushMessage { | ||
|
||
boolean isBroadcast(); | ||
|
||
String getUserId(); | ||
|
||
int getClientType(); | ||
|
||
byte[] getContent(); | ||
|
||
boolean isNeedAck(); | ||
|
||
byte getFlags(); | ||
|
||
int getTimeoutMills(); | ||
|
||
String getTaskId(); | ||
|
||
Condition getCondition(); | ||
|
||
default void finalized() { | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
mpush-api/src/main/java/com/mpush/api/spi/push/MessagePusher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* (C) Copyright 2015-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Contributors: | ||
* ohun@live.cn (夜色) | ||
*/ | ||
|
||
package com.mpush.api.spi.push; | ||
|
||
/** | ||
* Created by ohun on 2016/12/24. | ||
* | ||
* @author ohun@live.cn (夜色) | ||
*/ | ||
public interface MessagePusher { | ||
void push(IPushMessage message); | ||
} |
35 changes: 35 additions & 0 deletions
35
mpush-api/src/main/java/com/mpush/api/spi/push/MessagePusherFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* (C) Copyright 2015-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Contributors: | ||
* ohun@live.cn (夜色) | ||
*/ | ||
|
||
package com.mpush.api.spi.push; | ||
|
||
import com.mpush.api.spi.Factory; | ||
import com.mpush.api.spi.SpiLoader; | ||
|
||
/** | ||
* Created by ohun on 2016/12/24. | ||
* | ||
* @author ohun@live.cn (夜色) | ||
*/ | ||
public interface MessagePusherFactory extends Factory<MessagePusher> { | ||
|
||
static MessagePusher create() { | ||
return SpiLoader.load(MessagePusherFactory.class).get(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
mpush-api/src/main/java/com/mpush/api/spi/push/PushListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.mpush.api.spi.push; | ||
|
||
public interface PushListener<T extends IPushMessage> { | ||
|
||
/** | ||
* 消息下发成功后回调 | ||
* 如果消息需要ACK则该方法不会被调用 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onSuccess(T message); | ||
|
||
/** | ||
* 收到客户端ACK后回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onAckSuccess(T message); | ||
|
||
/** | ||
* 广播消息推送全部结束后回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onBroadcastComplete(T message); | ||
|
||
/** | ||
* 消息下发失败后回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onFailure(T message); | ||
|
||
/** | ||
* 推送消息发现用户不在线时回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onOffline(T message); | ||
|
||
/** | ||
* 推送消息发现用户不在当前机器时回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onRedirect(T message); | ||
|
||
/** | ||
* 等待客户端ACK超时时回调 | ||
* | ||
* @param message 要下发的消息 | ||
*/ | ||
void onAckTimeout(T message); | ||
} |
36 changes: 36 additions & 0 deletions
36
mpush-api/src/main/java/com/mpush/api/spi/push/PushListenerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* (C) Copyright 2015-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Contributors: | ||
* ohun@live.cn (夜色) | ||
*/ | ||
|
||
package com.mpush.api.spi.push; | ||
|
||
import com.mpush.api.spi.Factory; | ||
import com.mpush.api.spi.SpiLoader; | ||
|
||
/** | ||
* Created by ohun on 2016/12/24. | ||
* | ||
* @author ohun@live.cn (夜色) | ||
*/ | ||
public interface PushListenerFactory<M extends IPushMessage> extends Factory<PushListener<M>> { | ||
|
||
@SuppressWarnings("unchecked") | ||
static <M extends IPushMessage> PushListener<M> create() { | ||
return (PushListener<M>) SpiLoader.load(PushListenerFactory.class).get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.