-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Wrapped Messages and Responses
- Loading branch information
Showing
26 changed files
with
293 additions
and
75 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
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
50 changes: 50 additions & 0 deletions
50
common/src/main/java/au/com/grieve/geyserlink/message/messages/PingMessage.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,50 @@ | ||
/* | ||
* GeyserLink - The Missing Link | ||
* Copyright (C) 2020 GeyserLink Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyserlink.message.messages; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
|
||
@Getter | ||
@ToString(callSuper = true) | ||
public class PingMessage extends WrappedMessage { | ||
private final String channel = "geyserlink:main"; | ||
private final String subChannel = "ping"; | ||
|
||
private final String data; | ||
|
||
public PingMessage(String data) { | ||
super(); | ||
this.data = data; | ||
} | ||
|
||
public PingMessage(JsonNode node) { | ||
super(node); | ||
this.data = node.get("data").asText(); | ||
} | ||
|
||
@Override | ||
protected ObjectNode serialize() { | ||
return super.serialize() | ||
.put("data", data); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
common/src/main/java/au/com/grieve/geyserlink/message/messages/WrappedMessage.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 @@ | ||
/* | ||
* GeyserLink - The Missing Link | ||
* Copyright (C) 2020 GeyserLink Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyserlink.message.messages; | ||
|
||
import au.com.grieve.geyserlink.message.BaseMessage; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
public abstract class WrappedMessage extends BaseMessage { | ||
public WrappedMessage() { | ||
super(); | ||
} | ||
|
||
public WrappedMessage(JsonNode node) { | ||
super(node); | ||
} | ||
|
||
public abstract String getChannel(); | ||
|
||
public abstract String getSubChannel(); | ||
} |
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
48 changes: 48 additions & 0 deletions
48
common/src/main/java/au/com/grieve/geyserlink/message/responses/PingResponse.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,48 @@ | ||
/* | ||
* GeyserLink - The Missing Link | ||
* Copyright (C) 2020 GeyserLink Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyserlink.message.responses; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
|
||
@Getter | ||
@ToString(callSuper = true) | ||
public class PingResponse extends WrappedResponse { | ||
private final String data; | ||
|
||
public PingResponse(String data) { | ||
super(); | ||
|
||
this.data = data; | ||
} | ||
|
||
public PingResponse(JsonNode node) { | ||
super(node); | ||
this.data = node.get("data").asText(); | ||
} | ||
|
||
@Override | ||
protected ObjectNode serialize() { | ||
return super.serialize() | ||
.put("data", data); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
common/src/main/java/au/com/grieve/geyserlink/message/responses/WrappedResponse.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,33 @@ | ||
/* | ||
* GeyserLink - The Missing Link | ||
* Copyright (C) 2020 GeyserLink Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyserlink.message.responses; | ||
|
||
import au.com.grieve.geyserlink.message.BaseMessage; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
public abstract class WrappedResponse extends BaseMessage { | ||
|
||
public WrappedResponse() { | ||
super(); | ||
} | ||
|
||
public WrappedResponse(JsonNode node) { | ||
super(node); | ||
} | ||
} |
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.