[Feature]: Matchmaking Part1 #7
6 changed files with 241 additions and 6 deletions
|
@ -0,0 +1,15 @@
|
|||
package de.towerdefence.server.server.channels.matchmaking.in;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@NotNull
|
||||
public class MatchAcceptedMessage {
|
||||
public static final String MESSAGE_ID = "MatchAccepted";
|
||||
@JsonProperty("$id")
|
||||
private String messageId;
|
||||
private String matchId;
|
||||
private boolean accepted;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package de.towerdefence.server.server.channels.matchmaking.in;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@NotNull
|
||||
public class MatchSetSearchStateMessage {
|
||||
public static final String MESSAGE_ID = "MatchSetSearchState";
|
||||
@JsonProperty("$id")
|
||||
private String messageId;
|
||||
private boolean searching;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package de.towerdefence.server.server.channels.matchmaking.out;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import de.towerdefence.server.server.JsonMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MatchAbortedMessage extends JsonMessage {
|
||||
private String matchId;
|
||||
|
||||
@Override
|
||||
protected String getMessageId() {
|
||||
return "MatchAborted";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, JsonNode> getData(JsonNodeFactory factory) {
|
||||
return Map.of(
|
||||
"matchId", factory.textNode(this.matchId)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package de.towerdefence.server.server.channels.matchmaking.out;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import de.towerdefence.server.server.JsonMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MatchEstablishedMessage extends JsonMessage {
|
||||
private String matchId;
|
||||
private String opponentName;
|
||||
|
||||
@Override
|
||||
protected String getMessageId() {
|
||||
return "MatchEstablished";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, JsonNode> getData(JsonNodeFactory factory) {
|
||||
return Map.of(
|
||||
"matchId", factory.textNode(this.matchId),
|
||||
"opponentName", factory.textNode(this.opponentName)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package de.towerdefence.server.server.channels.matchmaking.out;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import de.towerdefence.server.server.JsonMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MatchFoundMessage extends JsonMessage {
|
||||
private String matchId;
|
||||
private long created;
|
||||
private long ttl;
|
||||
|
||||
@Override
|
||||
protected String getMessageId() {
|
||||
return "MatchFound";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, JsonNode> getData(JsonNodeFactory factory) {
|
||||
return Map.of(
|
||||
"matchId", factory.textNode(this.matchId),
|
||||
"created", factory.numberNode(this.created),
|
||||
"ttl", factory.numberNode(this.ttl)
|
||||
);
|
||||
}
|
||||
}
|
137
ws/ws.yml
137
ws/ws.yml
|
@ -39,9 +39,7 @@ channels:
|
|||
type: string
|
||||
format: messageId
|
||||
channel:
|
||||
type: string
|
||||
enum:
|
||||
- time
|
||||
$ref: "#/components/schemas/Channel"
|
||||
required:
|
||||
- $id
|
||||
- channel
|
||||
|
@ -58,15 +56,102 @@ channels:
|
|||
type: string
|
||||
format: messageId
|
||||
channel:
|
||||
type: string
|
||||
enum:
|
||||
- time
|
||||
$ref: "#/components/schemas/Channel"
|
||||
token:
|
||||
$ref: "#/components/schemas/JWT"
|
||||
required:
|
||||
- $id
|
||||
- channel
|
||||
- token
|
||||
|
||||
matchmaking:
|
||||
title: Matchmaking
|
||||
description: |
|
||||
A Channel used to search for a match and
|
||||
to receive one
|
||||
messages:
|
||||
MatchSetSearchState:
|
||||
payload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
$id:
|
||||
type: string
|
||||
format: messageId
|
||||
searching:
|
||||
type: boolean
|
||||
required:
|
||||
- $id
|
||||
- searching
|
||||
MatchFound:
|
||||
payload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
$id:
|
||||
type: string
|
||||
format: messageId
|
||||
matchId:
|
||||
type: string
|
||||
created:
|
||||
description: "Unix Timestamp describing when this Match was found"
|
||||
type: integer
|
||||
format: int64
|
||||
ttl:
|
||||
description: "Time in Milliseconds, how long this Match is open for accepting"
|
||||
type: integer
|
||||
format: int64
|
||||
required:
|
||||
- $id
|
||||
- matchId
|
||||
- created
|
||||
- ttl
|
||||
MatchAccepted:
|
||||
payload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
$id:
|
||||
type: string
|
||||
format: messageId
|
||||
matchId:
|
||||
type: string
|
||||
accepted:
|
||||
type: boolean
|
||||
required:
|
||||
- $id
|
||||
- matchId
|
||||
- accepted
|
||||
MatchAborted:
|
||||
payload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
$id:
|
||||
type: string
|
||||
format: messageId
|
||||
matchId:
|
||||
type: string
|
||||
required:
|
||||
- $id
|
||||
- matchId
|
||||
MatchEstablished:
|
||||
payload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
$id:
|
||||
type: string
|
||||
format: messageId
|
||||
matchId:
|
||||
type: string
|
||||
opponentName:
|
||||
type: string
|
||||
required:
|
||||
- $id
|
||||
- matchId
|
||||
- opponentName
|
||||
|
||||
time:
|
||||
title: Time
|
||||
description: |
|
||||
|
@ -102,6 +187,39 @@ operations:
|
|||
$ref: "#/channels/connection"
|
||||
messages:
|
||||
- $ref: "#/channels/connection/messages/ProvidedConnectionToken"
|
||||
searchMatch:
|
||||
title: SearchMatch
|
||||
action: send
|
||||
channel:
|
||||
$ref: "#/channels/matchmaking"
|
||||
messages:
|
||||
- $ref: "#/channels/matchmaking/messages/MatchSetSearchState"
|
||||
foundMatch:
|
||||
title: FoundGame
|
||||
action: receive
|
||||
channel:
|
||||
$ref: "#/channels/matchmaking"
|
||||
messages:
|
||||
- $ref: "#/channels/matchmaking/messages/MatchFound"
|
||||
reply:
|
||||
channel:
|
||||
$ref: "#/channels/matchmaking"
|
||||
messages:
|
||||
- $ref: "#/channels/matchmaking/messages/MatchAccepted"
|
||||
abortedMatch:
|
||||
title: AbortedMatch
|
||||
action: receive
|
||||
channel:
|
||||
$ref: "#/channels/matchmaking"
|
||||
messages:
|
||||
- $ref: "#/channels/matchmaking/messages/MatchAborted"
|
||||
establishedMatch:
|
||||
title: EstablishedMatch
|
||||
action: receive
|
||||
channel:
|
||||
$ref: "#/channels/matchmaking"
|
||||
messages:
|
||||
- $ref: "#/channels/matchmaking/messages/MatchEstablished"
|
||||
updateTime:
|
||||
title: Updates of the current Unix Time
|
||||
action: receive
|
||||
|
@ -124,3 +242,10 @@ components:
|
|||
JWT:
|
||||
type: string
|
||||
format: jwt
|
||||
Channel:
|
||||
type: string
|
||||
enum:
|
||||
- connection
|
||||
- matchmaking
|
||||
- time
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue