-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addresses multiple intertwining issues. #166
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8578bea
Addresses multiple intertwining issues.
CoreyShupe 611e144
Removed useless @Nullables, assumed null by convention.
CoreyShupe 56006e1
Better sharding assertion, 0counting num, 1counting total.
CoreyShupe 1cb99c9
Removed termination exiting.
CoreyShupe 5e01f47
Moved closed on test to the end of the method.
CoreyShupe 48ea8cf
Fixed json issue with `Identify`.
CoreyShupe 1ddce21
Changes based on comments in base PR.
CoreyShupe a2d8163
Changes based on comments in base PR.
CoreyShupe e28614a
Refactored sharding from config.
CoreyShupe 37187e8
Testing `test`s fix.
CoreyShupe 4ba0fe2
Test fixes.
CoreyShupe 62e34ea
Formatting + shard exception throwing when 1 value present.
CoreyShupe 513d66e
Fixed sharding assertion and added tests for config creation.
CoreyShupe cc7076e
Styling.
CoreyShupe 2d90faa
Reverting Robot.
CoreyShupe c8a2cbb
General style fixes.
CoreyShupe a4f5a71
Styling updates + shard changes.
CoreyShupe de71711
Gatewaycommand updates, probably not the last revision.
CoreyShupe af8714d
Travis happiness.
CoreyShupe 9107b15
Merge branch 'master' into master
CoreyShupe 159b44f
Stripped certain pieces and moved others.
CoreyShupe ea62d00
Small spotless fix.
CoreyShupe f4f76ab
Merge branch 'master' into master
CoreyShupe b0114e9
Unused item reduction.
CoreyShupe 0d4f0bd
Merge branch 'master' into master
CoreyShupe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we avoid this optional by having using a Shard of [0,1] as a default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having no sharding is a bit safer, I dont think telling discord we are using shard [0,1] is useful and Optional makes sense and looks like what it does.