You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Developer Documentation/commons.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ sidebar_position: 2
4
4
# Commons
5
5
This [repository](https://github.com/TrailCompass/commons) is the glue, holding the entire software together. It consists of two main parts. API part is an implementation of the communication protocol, Proto part defines the entire protocol, including all shared objects.
6
6
7
-
## Protocol
7
+
## Protocol {#protocol}
8
8
This part of the commons repository contains the exchange definitions, exchanged objects, request and response packets and utilities, needed for generic exchanges. Exchange definitions are written like interfaces in the following style:
9
9
```java
10
10
publicinterfaceIExchange {
@@ -24,5 +24,17 @@ In the demo provided above, this subexchange, called `ITestExchange`, defines tw
24
24
25
25
The same can be said about `castCardWithOtherCard()` method. It consumes [`CastCardWithOtherCardRequest`](https://github.com/TrailCompass/commons/blob/main/src/main/java/space/itoncek/trailcompass/proto/requests/deck/CastCardWithOtherCardRequest.java), which is a record, containing the token of a player, `UUID` of the cast card and `UUID` of another card from hider's deck. It returns [`OkResponse`](https://github.com/TrailCompass/commons/blob/main/src/main/java/space/itoncek/trailcompass/proto/responses/generic/OkResponse.java), which is equivalent to `void` return type in Java.
26
26
27
-
# Creating a subexchange
28
-
Every subexchange should represent a different module of the TrailCompass protocol. For example, all the packets related to login and authentication should be contained within one subexchange, in this case called [`IAuthExchange`](https://github.com/TrailCompass/commons/blob/main/src/main/java/space/itoncek/trailcompass/proto/exchange/IAuthExchange.java).
27
+
# Creating a subexchange {#creating-subexchanges}
28
+
Every subexchange should represent a different module of the TrailCompass protocol. For example, all the packets related to login and authentication should be contained within one subexchange, in this case called [`IAuthExchange`](https://github.com/TrailCompass/commons/blob/main/src/main/java/space/itoncek/trailcompass/proto/exchange/IAuthExchange.java).
29
+
30
+
When creating a new subexchange, you should first define the exchange's methods and packet definitions (this will be explained [later](#packet-definitions)). This should be written in the following format:
0 commit comments