-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,110 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using EFT; | ||
using EFT.Bots; | ||
using JsonType; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Fika.Core.Models | ||
{ | ||
[DataContract] | ||
public struct SetDedicatedStatusRequest | ||
{ | ||
[DataMember(Name = "sessionId")] | ||
public string SessionId { get; set; } | ||
|
||
[DataMember(Name = "status")] | ||
public string Status { get; set; } | ||
|
||
public SetDedicatedStatusRequest(string sessionId, string status) | ||
{ | ||
SessionId = sessionId; | ||
Status = status; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fika.Core.Models | ||
{ | ||
[DataContract] | ||
public struct SetDedicatedStatusResponse | ||
{ | ||
[DataMember(Name = "sessionId")] | ||
public string SessionId { get; set; } | ||
|
||
[DataMember(Name = "status")] | ||
public string Status { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using EFT; | ||
using EFT.Bots; | ||
using JsonType; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Fika.Core.Models | ||
{ | ||
[DataContract] | ||
public struct StartDedicatedRequest | ||
{ | ||
[DataMember(Name = "expectedNumberOfPlayers")] | ||
public int ExpectedNumPlayers { get; set; } | ||
|
||
[DataMember(Name = "time")] | ||
public EDateTime Time { get; set; } | ||
|
||
[DataMember(Name = "locationId")] | ||
public string LocationId { readonly get; set; } | ||
|
||
[DataMember(Name = "spawnPlace")] | ||
public EPlayersSpawnPlace SpawnPlace { readonly get; set; } | ||
|
||
[DataMember(Name = "metabolismDisabled")] | ||
public bool MetabolismDisabled { readonly get; set; } | ||
|
||
[DataMember(Name = "timeAndWeatherSettings")] | ||
public TimeAndWeatherSettings TimeAndWeatherSettings { readonly get; set; } | ||
|
||
[DataMember(Name = "botSettings")] | ||
public BotControllerSettings BotSettings { readonly get; set; } | ||
|
||
[DataMember(Name = "wavesSettings")] | ||
public WavesSettings WavesSettings { readonly get; set; } | ||
|
||
[DataMember(Name = "side")] | ||
public ESideType Side { readonly get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Fika.Core.Models | ||
{ | ||
[DataContract] | ||
public struct StartDedicatedResponse | ||
{ | ||
[DataMember(Name = "matchId")] | ||
public string MatchId { get; set; } | ||
|
||
[DataMember(Name = "error")] | ||
public string Error { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
using BepInEx.Logging; | ||
using EFT.UI.Matchmaker; | ||
using EFT.UI; | ||
using EFT; | ||
using Fika.Core.UI.Custom; | ||
using LiteNetLib; | ||
using SPT.Common.Http; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
using WebSocketSharp; | ||
using HarmonyLib; | ||
using Newtonsoft.Json.Linq; | ||
using Comfort.Common; | ||
|
||
namespace Fika.Core.Networking | ||
{ | ||
public class FikaDedicatedWebSocket | ||
{ | ||
private static ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("Fika.DedicatedWebSocket"); | ||
|
||
public string Host { get; set; } | ||
public string Url { get; set; } | ||
public string SessionId { get; set; } | ||
public bool Connected | ||
{ | ||
get | ||
{ | ||
return _webSocket.ReadyState == WebSocketState.Open; | ||
} | ||
} | ||
|
||
private WebSocket _webSocket; | ||
|
||
public FikaDedicatedWebSocket() | ||
{ | ||
Host = RequestHandler.Host.Replace("http", "ws"); | ||
SessionId = RequestHandler.SessionId; | ||
Url = $"{Host}/fika/dedicatedraidservice/{SessionId}?"; | ||
|
||
_webSocket = new WebSocket(Url) | ||
{ | ||
WaitTime = TimeSpan.FromMinutes(1), | ||
EmitOnPing = true | ||
}; | ||
|
||
_webSocket.OnOpen += WebSocket_OnOpen; | ||
//_webSocket.OnError += WebSocket_OnError; | ||
_webSocket.OnMessage += WebSocket_OnMessage; | ||
//_webSocket.OnClose += WebSocket_OnClose; | ||
} | ||
|
||
public void Connect() | ||
{ | ||
_webSocket.Connect(); | ||
} | ||
|
||
public void Close() | ||
{ | ||
_webSocket.Close(); | ||
} | ||
|
||
|
||
private void WebSocket_OnOpen(object sender, EventArgs e) | ||
{ | ||
logger.LogInfo("Connected to FikaNatPunchRelayService as server"); | ||
} | ||
|
||
private void WebSocket_OnMessage(object sender, MessageEventArgs e) | ||
{ | ||
if (e == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (string.IsNullOrEmpty(e.Data)) | ||
{ | ||
return; | ||
} | ||
|
||
JObject jsonObject = JObject.Parse(e.Data); | ||
|
||
if(!jsonObject.ContainsKey("type")) | ||
{ | ||
return; | ||
} | ||
|
||
string type = jsonObject["type"].ToString(); | ||
|
||
switch (type) | ||
{ | ||
case "fikaDedicatedJoinMatch": | ||
|
||
ConsoleScreen.Log("received fikaJoinMatch"); | ||
string matchId = jsonObject.Value<string>("matchId"); | ||
MatchMakerAcceptScreen matchMakerAcceptScreen = GameObject.FindObjectOfType<MatchMakerAcceptScreen>(); | ||
if (matchMakerAcceptScreen == null) | ||
{ | ||
PreloaderUI.Instance.ShowErrorScreen("Fika Dedicated Error", "Failed to find MatchMakerAcceptScreen", () => | ||
{ | ||
var acceptScreen = GameObject.FindObjectOfType<MatchMakerAcceptScreen>(); | ||
var controller = Traverse.Create(acceptScreen).Field<MatchMakerAcceptScreen.GClass3177>("ScreenController").Value; | ||
controller.CloseScreen(); | ||
}); | ||
|
||
return; | ||
} | ||
|
||
if (matchId is not null) | ||
{ | ||
//Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.QuestCompleted); | ||
TarkovApplication tarkovApplication = (TarkovApplication)Singleton<ClientApplication<ISession>>.Instance; | ||
tarkovApplication.StartCoroutine(MatchMakerUIScript.JoinMatch(tarkovApplication.Session.Profile.Id, matchId, null, () => | ||
{ | ||
Traverse.Create(matchMakerAcceptScreen).Field<DefaultUIButton>("_acceptButton").Value.OnClick.Invoke(); | ||
})); | ||
} | ||
else | ||
{ | ||
PreloaderUI.Instance.ShowErrorScreen("Fika Dedicated Error", "Received fikaJoinMatch WS event but there was no matchId", () => | ||
{ | ||
var acceptScreen = GameObject.FindObjectOfType<MatchMakerAcceptScreen>(); | ||
var controller = Traverse.Create(acceptScreen).Field<MatchMakerAcceptScreen.GClass3177>("ScreenController").Value; | ||
controller.CloseScreen(); | ||
}); | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.