-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Showing
14 changed files
with
157 additions
and
81 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.shinemo.mpush.api; | ||
|
||
import com.shinemo.mpush.api.protocol.Packet; | ||
|
||
/** | ||
* Created by ohun on 2015/12/22. | ||
*/ | ||
public interface Receiver { | ||
void onMessage(Request request); | ||
void onMessage(Packet packet, Connection connection); | ||
} |
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
21 changes: 4 additions & 17 deletions
21
mpush-api/src/main/java/com/shinemo/mpush/api/Response.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 |
---|---|---|
@@ -1,26 +1,13 @@ | ||
package com.shinemo.mpush.api; | ||
|
||
import com.shinemo.mpush.api.protocol.Packet; | ||
|
||
/** | ||
* Created by ohun on 2015/12/22. | ||
*/ | ||
public class Response { | ||
private final Packet packet; | ||
private final Connection connection; | ||
|
||
public Response(Packet packet, Connection connection) { | ||
this.packet = packet; | ||
this.connection = connection; | ||
} | ||
|
||
public void send(byte[] body) { | ||
packet.body = body; | ||
connection.send(packet); | ||
} | ||
public interface Response { | ||
|
||
void send(byte[] body); | ||
|
||
public void sendError(byte[] reson) { | ||
void sendRaw(byte[] body); | ||
|
||
} | ||
void sendError(byte[] reason); | ||
} |
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
42 changes: 42 additions & 0 deletions
42
mpush-core/src/main/java/com/shinemo/mpush/core/message/NettyRequest.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,42 @@ | ||
package com.shinemo.mpush.core.message; | ||
|
||
import com.shinemo.mpush.api.Connection; | ||
import com.shinemo.mpush.api.Request; | ||
import com.shinemo.mpush.api.Response; | ||
import com.shinemo.mpush.api.protocol.Command; | ||
import com.shinemo.mpush.api.protocol.Packet; | ||
|
||
/** | ||
* Created by ohun on 2015/12/22. | ||
*/ | ||
public class NettyRequest implements Request{ | ||
private final Command command; | ||
private final Packet message; | ||
private final Connection connection; | ||
|
||
public NettyRequest(Packet message, Connection connection) { | ||
this.message = message; | ||
this.connection = connection; | ||
this.command = Command.toCMD(message.command); | ||
} | ||
|
||
public Command getCommand() { | ||
return command; | ||
} | ||
|
||
public Packet getMessage() { | ||
return message; | ||
} | ||
|
||
public Connection getConnection() { | ||
return connection; | ||
} | ||
|
||
public Response getResponse() { | ||
Packet packet = new Packet(); | ||
packet.command = message.command; | ||
packet.msgId = message.msgId; | ||
packet.version = message.version; | ||
return new NettyResponse(packet, connection); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
mpush-core/src/main/java/com/shinemo/mpush/core/message/NettyResponse.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,34 @@ | ||
package com.shinemo.mpush.core.message; | ||
|
||
import com.shinemo.mpush.api.Connection; | ||
import com.shinemo.mpush.api.Response; | ||
import com.shinemo.mpush.api.protocol.Packet; | ||
import com.shinemo.mpush.tools.crypto.DESUtils; | ||
|
||
/** | ||
* Created by ohun on 2015/12/22. | ||
*/ | ||
public class NettyResponse implements Response { | ||
private final Packet packet; | ||
private final Connection connection; | ||
|
||
public NettyResponse(Packet packet, Connection connection) { | ||
this.packet = packet; | ||
this.connection = connection; | ||
} | ||
|
||
public void send(byte[] body) { | ||
packet.body = DESUtils.decryptDES(body, connection.getInfo().desKey); | ||
connection.send(packet); | ||
} | ||
|
||
public void sendRaw(byte[] body) { | ||
packet.body = body; | ||
connection.send(packet); | ||
} | ||
|
||
|
||
public void sendError(byte[] reason) { | ||
|
||
} | ||
} |
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.