TD-18: Add Specification of Matchmaking Channel and Creation of Type
Some checks failed
Quality Check / Validate OAS (push) Successful in 32s
Quality Check / Linting (push) Failing after 48s
Quality Check / Testing (push) Successful in 56s
Quality Check / Static Analysis (push) Successful in 58s

This commit is contained in:
Snoweuph 2025-02-19 11:38:00 +01:00
parent f6afeed945
commit ada41d3340
Signed by: snoweuph
GPG key ID: BEFC41DA223CEC55
6 changed files with 241 additions and 6 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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)
);
}
}

View file

@ -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)
);
}
}

View file

@ -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
View file

@ -39,9 +39,7 @@ channels:
type: string type: string
format: messageId format: messageId
channel: channel:
type: string $ref: "#/components/schemas/Channel"
enum:
- time
required: required:
- $id - $id
- channel - channel
@ -58,15 +56,102 @@ channels:
type: string type: string
format: messageId format: messageId
channel: channel:
type: string $ref: "#/components/schemas/Channel"
enum:
- time
token: token:
$ref: "#/components/schemas/JWT" $ref: "#/components/schemas/JWT"
required: required:
- $id - $id
- channel - channel
- token - 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: time:
title: Time title: Time
description: | description: |
@ -102,6 +187,39 @@ operations:
$ref: "#/channels/connection" $ref: "#/channels/connection"
messages: messages:
- $ref: "#/channels/connection/messages/ProvidedConnectionToken" - $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: updateTime:
title: Updates of the current Unix Time title: Updates of the current Unix Time
action: receive action: receive
@ -124,3 +242,10 @@ components:
JWT: JWT:
type: string type: string
format: jwt format: jwt
Channel:
type: string
enum:
- connection
- matchmaking
- time