Compare commits

..

No commits in common. "b378ff26898876b6a8976a6d9086708a05672110" and "12981bfa615f2b159254b313af663d91c292fd85" have entirely different histories.

2 changed files with 0 additions and 31 deletions

View File

@ -74,28 +74,6 @@ public class ApiWebService
} catch (Exception e) { LogError(e.Message); return false; }
}
public bool SetOnline(Client client, bool online)
{
HttpClient httpClient = new();
var content = new FormUrlEncodedContent
(
new Dictionary<string, string>
{
{ "token", client.PlayerData.UNToken },
{ "online", online.ToString() }
}
);
try
{
var response = httpClient.PostAsync($"{Configuration.ServerConfiguration.ApiUrl}/Precense/SetVikingOnline", content).Result;
Log("Precense/SetVikingOnline");
if (response.StatusCode == System.Net.HttpStatusCode.OK && response.Content != null) return response.Content.ReadFromJsonAsync<bool>().Result;
else return false;
} catch (Exception e) { LogError(e.Message); return false; }
}
private void Log(string endpoint) => Console.WriteLine($"Sent API Request To {Configuration.ServerConfiguration.ApiUrl}/{endpoint}");
private void LogError(string message) => Console.WriteLine($"An Error Has Occured When Sending An API Request - {message}");

View File

@ -47,9 +47,6 @@ public class Client {
}
public void SetRoom(Room? room) {
// api web service for setting precense
ApiWebService apiWebService = new();
lock(clientLock) {
// set variable player data as not valid, but do not reset all player data
PlayerData.IsValid = false;
@ -62,8 +59,6 @@ public class Client {
data.Add("r", Room.Id);
data.Add("u", ClientID);
Room.Send(NetworkObject.WrapObject(0, 1004, data).Serialize());
apiWebService.SetOnline(this, false);
}
// set new room (null when SetRoom is used as LeaveRoom)
@ -75,8 +70,6 @@ public class Client {
Send(Room.SubscribeRoom());
if (Room.Name != "LIMBO") UpdatePlayerUserVariables(); // do not update user vars if room is limbo
apiWebService.SetOnline(this, true);
}
}
}
@ -105,13 +98,11 @@ public class Client {
}
public void ScheduleDisconnect() {
ApiWebService apiWebService = new();
if (Room != null) {
// quiet remove from room (to avoid issues in Room.Send)
// - do not change Room value here
// - full remove will be will take place Server.HandleClient (before real disconnected)
Room.RemoveClient(this);
apiWebService.SetOnline(this, false);
}
scheduledDisconnect = true;
}