-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from CoreyShupe/master
Addresses multiple intertwining issues.
- Loading branch information
Showing
13 changed files
with
274 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
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/github/princesslana/eriscasper/gateway/commands/GatewayCommand.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,8 @@ | ||
package com.github.princesslana.eriscasper.gateway.commands; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.github.princesslana.eriscasper.gateway.Payload; | ||
|
||
public interface GatewayCommand { | ||
Payload toPayload(ObjectMapper jackson); | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/github/princesslana/eriscasper/gateway/commands/Identify.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,60 @@ | ||
package com.github.princesslana.eriscasper.gateway.commands; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.github.princesslana.eriscasper.BotToken; | ||
import com.github.princesslana.eriscasper.gateway.ImmutablePayload; | ||
import com.github.princesslana.eriscasper.gateway.OpCode; | ||
import com.github.princesslana.eriscasper.gateway.Payload; | ||
import com.github.princesslana.eriscasper.util.Shard; | ||
import java.util.Optional; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* @see <a href="https://discordapp.com/developers/docs/topics/gateway#identify"> | ||
* https://discordapp.com/developers/docs/topics/gateway#identify</a> | ||
*/ | ||
// TODO: This structure is not complete | ||
@JsonDeserialize(as = ImmutableIdentify.class) | ||
@Value.Immutable | ||
@Value.Enclosing | ||
public interface Identify extends GatewayCommand { | ||
BotToken getToken(); | ||
|
||
Optional<Shard> shard(); | ||
|
||
default ConnectionProperties getProperties() { | ||
return ConnectionProperties.ofDefault(); | ||
} | ||
|
||
@Override | ||
default Payload toPayload(ObjectMapper jackson) { | ||
return ImmutablePayload.builder().op(OpCode.IDENTIFY).d(jackson.valueToTree(this)).build(); | ||
} | ||
|
||
/** | ||
* @see <a | ||
* href="https://discordapp.com/developers/docs/topics/gateway#identify-identify-connection-properties"> | ||
* https://discordapp.com/developers/docs/topics/gateway#identify-identify-connection-properties</a> | ||
*/ | ||
@Value.Immutable | ||
interface ConnectionProperties { | ||
@JsonProperty("$os") | ||
String getOs(); | ||
|
||
@JsonProperty("$browser") | ||
String getBrowser(); | ||
|
||
@JsonProperty("$device") | ||
String getDevice(); | ||
|
||
static ConnectionProperties ofDefault() { | ||
return ImmutableIdentify.ConnectionProperties.builder() | ||
.os(System.getProperty("os.name")) | ||
.browser("ErisCasper.java") | ||
.device("ErisCasper.java") | ||
.build(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/princesslana/eriscasper/gateway/commands/Resume.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,30 @@ | ||
package com.github.princesslana.eriscasper.gateway.commands; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.github.princesslana.eriscasper.BotToken; | ||
import com.github.princesslana.eriscasper.gateway.ImmutablePayload; | ||
import com.github.princesslana.eriscasper.gateway.OpCode; | ||
import com.github.princesslana.eriscasper.gateway.Payload; | ||
import com.github.princesslana.eriscasper.gateway.SequenceNumber; | ||
import com.github.princesslana.eriscasper.gateway.SessionId; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* @see <a href="https://discordapp.com/developers/docs/topics/gateway#resume"> | ||
* https://discordapp.com/developers/docs/topics/gateway#resume</a> | ||
*/ | ||
@Value.Immutable | ||
public interface Resume extends GatewayCommand { | ||
BotToken getToken(); | ||
|
||
@JsonProperty("session_id") | ||
SessionId getSessionId(); | ||
|
||
SequenceNumber getSeq(); | ||
|
||
@Override | ||
default Payload toPayload(ObjectMapper jackson) { | ||
return ImmutablePayload.builder().op(OpCode.RESUME).d(jackson.valueToTree(this)).build(); | ||
} | ||
} |
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.