Subterfuge-Revived / Remake-Core

Core repository that holds all game logic for both front end rendering and back end validation.
Creative Commons Zero v1.0 Universal
39 stars 24 forks source link

Networking #15

Closed QuinnBast closed 4 years ago

QuinnBast commented 4 years ago

Description

Additional Flexibility

Updated the Api class to include more detailed information about network requests. THe Api now wraps all responses in a NetworkResponse<T> class. The templated class, T, is the class representation of the JSON object that is returned from the response. When the network response is returned, if a failure occurs, the NetworkResponse object now stores the original HttpResponseMessage as well as the raw string content of the request and the status code. This makes it easier for the frontend to be able to handle various failure cases. If the response is a success, the NetworkResponse class will attempt to cast the JSON string in the response into the templated type, T. If unsuccessfully able to cast to the templated type, a null object is set in the NetworkResponse.Response object.

This change also changes the API's URL to be a static member. This means that you no longer have to call Api api = new Api(serverUrl), you can simply set the URL once and it will remember the URL. This resolves #9

New Endpoints

Multiple new endpoints were also added to the Api class which reflect the backend API's endpoints. These endpoints include the ability to block other players, create group chats, as well as send and receive messages from a group. This resolves #8

Type of change

CLI

Core

Testing

Checklist:

This module contains breaking changes to Unity users. However, the respective changes to the Unity dll have been made on an appropraite branch and should be merged in to master when this PR is accepted.

QuinnBast commented 4 years ago

Updated API module to work with the latest backend updates.

image image image image image

Problems with creating a message group. See https://github.com/Subterfuge-Revived/Remake-Backend/issues/28

image image image image image

QuinnBast commented 4 years ago

These commits should fix up everything that was mentioned

griendt commented 4 years ago

The "enforced tempalte [sic] type" commit secretly contains other changes ;-) But I approve of them so you have my blessing 👍