|
3 | 3 | ## Current Features
|
4 | 4 |
|
5 | 5 | - [x] Announcements
|
6 |
| -- [x] Mail |
7 |
| -- [ ] Logging in |
| 6 | +- [x] Logging in |
| 7 | +- [x] Updates |
| 8 | +- [ ] Mail |
8 | 9 | - [ ] Missions
|
9 | 10 | - [ ] Registering
|
10 |
| -- [ ] Updates |
11 | 11 | - [ ] Gacha
|
12 | 12 | - [ ] Events
|
13 | 13 | - [ ] Items & Rewards
|
14 |
| -- [ ] Operations / Gameplay |
15 |
| - |
16 |
| -## Startup |
17 |
| - |
18 |
| -### Getting Started |
19 |
| - |
20 |
| -When starting up the server, the client only needs to connect for a couple seconds, where then it is safe to disconnect after the update has been installed. This is because the game uses a system where it only stores the remote config file. If you are running on a public Doctorate server, you will get all the updates a normal user would get, this is because Doctorate actually requests the updates from Official Servers on behalf of you and passes back adjusted data! |
21 |
| - |
22 |
| -```mermaid |
23 |
| -sequenceDiagram |
24 |
| -Client ->> Proxy: GET [HOST] /remote_config |
25 |
| -Proxy ->> Server: GET [FAKEHOST] /remote_config |
26 |
| -Server--> Client: Response [FAKEHOST] {"gs":"[FAKEHOST]", "as":"[FAKEHOST]"... |
27 |
| -Note right of Server: Client now thinks that<br> the [FAKEHOST] is the<br> real host, and sends all<br> requests to that server. |
28 |
| -Client ->> Server: GET [FAKEHOST] /announce/version |
29 |
| -Server--> Client: Reponse [FAKEHOST] {"resVersion":"22-04-21-10-53-07-1be683"... |
30 |
| -Note right of Server: Server sends a version that<br> is greater than the clients<br> current version, causing<br> an update to be requested,<br> which in return, changes<br> the default host. |
31 |
| -Client ->> Server: GET [FAKEHOST] /update |
32 |
| -Server--> Client: Response [FAKEHOST] *Update Patch* |
33 |
| -Client ->> Server: POST [FAKEHOST] /user/login |
34 |
| -``` |
35 |
| - |
36 |
| -## Creating a new Router |
37 |
| - |
38 |
| -Doctorate uses a module system to register new API routes. Each router "package" is enclosed inside the router. For example, say the game has a new path called "shop", this would be the folder name and then any routes under it are registered accordingly. |
39 |
| - |
40 |
| -```mermaid |
41 |
| -graph TD |
42 |
| -A[Router] |
43 |
| -A --> |/api/shop| B(package shop) |
44 |
| -A --> |/api/announce| C(package announce) |
45 |
| -A --> |/api/quest| D(package quest) |
46 |
| -``` |
47 |
| -We can create a new package by simply doing something like the following: |
48 |
| -```go |
49 |
| -// '/router/test/test.go' |
50 |
| -package test |
51 |
| - |
52 |
| -// Import the router package |
53 |
| -import ( |
54 |
| - "github.com/Etwodev/Doctorate/server/router" |
55 |
| -) |
56 |
| - |
57 |
| -func NewRouter(status bool) router.Router { |
58 |
| - // Automatically creates missing tables and more for us |
59 |
| - router.Connector.AutoMigrate(&Test{}) |
60 |
| - return router.NewRouter(initRoutes(), status) |
61 |
| -} |
62 |
| - |
63 |
| -func initRoutes() []router.Route { |
64 |
| - return []router.Route{ |
65 |
| - // path, isExperimental, isActivated, method |
66 |
| - router.NewGetRoute("/test/test", true, true, TestPostRoute), |
67 |
| - } |
68 |
| -} |
69 |
| -``` |
70 |
| -TestPostRoute may look something like this: |
71 |
| -```go |
72 |
| -// '/router/test/test_routes.go |
73 |
| -package test |
74 |
| - |
75 |
| -import ( |
76 |
| - "net/http" |
77 |
| - "github.com/Etwodev/Doctorate/server/httputils" |
78 |
| - "github.com/Etwodev/Doctorate/server/router" |
79 |
| -) |
80 |
| - |
81 |
| -func TestPostRoute(w http.ResponseWriter, r *http.Request) { |
82 |
| - var t Test |
83 |
| - // Gets all data relating to the object Test |
84 |
| - router.Connector.Find(&t) |
85 |
| - httputils.RespondWithJSON(w, http.StatusOK, pre) |
86 |
| -} |
87 |
| -``` |
88 |
| - |
89 |
| -We need to make sure we update our main.go file, though! |
90 |
| -This is to make sure the router gets initialised and we don't get an empty router. |
91 |
| -```go |
92 |
| -// main.go |
93 |
| -... |
94 |
| -routers := []router.Router{ |
95 |
| - // We call NewRouter(), where "true" is whether the route is should be activated |
96 |
| - test.NewRouter(true), |
97 |
| -} |
98 |
| - |
99 |
| -// Initilises all the routers |
100 |
| -s.InitRouter(routers...) |
101 |
| -// In this case, "true" is whether or not to run the server in experimental mode |
102 |
| -var r = s.InitRouters(true) |
103 |
| -... |
104 |
| -``` |
105 |
| - |
| 14 | +- [ ] Operations / Gameplay |
0 commit comments