Skip to content

Commit 00080fe

Browse files
Merge pull request #1160 from EOS-Contrib/Update-EOS-1.17.1-43712763-9dca
Update EOS SDK 1.17.1.0-43712763-9dca
2 parents 082c9a1 + 7c691f8 commit 00080fe

File tree

1,173 files changed

+33652
-55011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,173 files changed

+33652
-55011
lines changed

Assets/Plugins/Linux/Core/LinuxPlatformSpecifics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public override void LoadDelegatesWithEOSBindingAPI()
6565
{
6666
#if EOS_DYNAMIC_BINDINGS || UNITY_EDITOR
6767
// TODO: This code does not appear to do anything...
68-
const string EOSBinaryName = Epic.OnlineServices.Config.LibraryName;
68+
const string EOSBinaryName = Epic.OnlineServices.Common.LIBRARY_NAME;
6969
var eosLibraryHandle = EOSManager.EOSSingleton.LoadDynamicLibrary(EOSBinaryName);
7070
#endif
7171
}

Assets/Plugins/Windows/Core/WindowsPlatformSpecifics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override void LoadDelegatesWithEOSBindingAPI()
9595
{
9696
// In the editor, EOS needs to be dynamically bound.
9797
#if EOS_DYNAMIC_BINDINGS || UNITY_EDITOR
98-
const string EOSBinaryName = Epic.OnlineServices.Config.LibraryName;
98+
const string EOSBinaryName = Epic.OnlineServices.Common.LIBRARY_NAME;
9999
var eosLibraryHandle = EOSManager.EOSSingleton.LoadDynamicLibrary(EOSBinaryName);
100100
Epic.OnlineServices.WindowsBindings.Hook<DLLHandle>(eosLibraryHandle, (DLLHandle handle, string functionName) => {
101101
return handle.LoadFunctionAsIntPtr(functionName);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:9d8f034fe2e08482bc0a131702fd9a4066337fc5149527c8b1877a870b6ac9a4
3-
size 122880
2+
oid sha256:2f957da436d0ad17909ae2d192d6ab4b1836ce0c09a165ad234d112474f0e3e1
3+
size 125440
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:71d77cd8cb1d153472ab5d01e9ae62f7415c95c0baa8c4e54cc856fc2842e758
3-
size 604672
2+
oid sha256:1da114c20fc09c662b54bb089383189f0a94f83bac57e1d13afd11f26f39ee1d
3+
size 636416
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:cb8494abca7f617353dd1e1f900ead28a1de316dc84779b63bcf74efcd83ef74
3-
size 87040
2+
oid sha256:c3ede5c79d720914671c994d42f50149d701aba4b2c5cf100995d1af7cccb34b
3+
size 110592
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:ac77b32eaebef7dc1c75aa070bc92ca521ede00c70dcf0c6b5262c3430a5d2c7
3-
size 467968
2+
oid sha256:49f41bf1f6308319f8495b1a1be9e2e634ae03e6a7e6367806e42fffab4620b0
3+
size 483328

Assets/Scripts/EOSFriendsManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public void SubscribeToFriendUpdates(EpicAccountId userId)
817817
var addNotifyFriendsUpdateOptions = new AddNotifyFriendsUpdateOptions();
818818
ulong notificationId = FriendsHandle.AddNotifyFriendsUpdate(ref addNotifyFriendsUpdateOptions, null, OnFriendsUpdateCallbackHandler);
819819

820-
if(notificationId == Common.InvalidNotificationid)
820+
if(notificationId == Common.INVALID_NOTIFICATIONID)
821821
{
822822
Debug.LogError("Friends (SubscribeToFriendUpdates): Could not subscribe to friend update notifications.");
823823
}
@@ -830,7 +830,7 @@ public void SubscribeToFriendUpdates(EpicAccountId userId)
830830
var addNotifyOnPresenceChangedOptions = new AddNotifyOnPresenceChangedOptions();
831831
ulong presenceNotificationId = PresenceHandle.AddNotifyOnPresenceChanged(ref addNotifyOnPresenceChangedOptions , null, OnPresenceChangedCallbackHandler);
832832

833-
if(presenceNotificationId == Common.InvalidNotificationid)
833+
if(presenceNotificationId == Common.INVALID_NOTIFICATIONID)
834834
{
835835
Debug.LogError("Friends (SubscribeToFriendUpdates): Could not subscribe to presence changed notifications.");
836836
}

Assets/Scripts/EOSPeer2PeerManager.cs

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ public class EOSPeer2PeerManager : IEOSSubManager
8989

9090
public UIPeer2PeerParticleController ParticleController;
9191
public Transform parent;
92+
private enum PeerConnectionAppState
93+
{
94+
NotConnected,
95+
IceConnected,
96+
HandshakePending,
97+
FullyConnected
98+
}
99+
100+
private Dictionary<ProductUserId, PeerConnectionAppState> connectionStates = new();
101+
102+
private string Request = "hreq";
103+
private string Acknowledgement = "hack";
104+
private string Ping = "ping";
92105

93106
#if UNITY_EDITOR
94107
void OnPlayModeChanged(UnityEditor.PlayModeStateChange modeChange)
@@ -126,7 +139,19 @@ public bool GetChatDataCache(out Dictionary<ProductUserId, ChatWithFriendData> C
126139
ChatDataCache = this.ChatDataCache;
127140
return ChatDataCacheDirty;
128141
}
142+
public void Initialize()
143+
{
144+
SubscribeToConnectionRequest();
145+
146+
var options = new AddNotifyPeerConnectionEstablishedOptions
147+
{
148+
LocalUserId = EOSManager.Instance.GetProductUserId()
149+
};
129150

151+
P2PHandle.AddNotifyPeerConnectionEstablished(ref options, null, OnPeerConnectionEstablished);
152+
153+
Debug.Log("EOSPeer2PeerManager initialized: connection listeners registered.");
154+
}
130155
private void RefreshNATType()
131156
{
132157
var options = new QueryNATTypeOptions();
@@ -188,6 +213,12 @@ public void SendMessage(ProductUserId friendId, messageData message)
188213
Debug.LogError("EOS P2PNAT SendMessage: bad input data: account id is wrong.");
189214
return;
190215
}
216+
if (!connectionStates.TryGetValue(friendId, out var state) || state != PeerConnectionAppState.FullyConnected)
217+
{
218+
Debug.LogWarning($"SendMessage: Cannot send to {friendId}, not fully connected (State={state}).");
219+
return;
220+
}
221+
191222
if (message.type == messageType.textMessage)
192223
{
193224
if (string.IsNullOrEmpty(message.textData))
@@ -283,6 +314,8 @@ public void SendMessage(ProductUserId friendId, messageData message)
283314

284315
public ProductUserId HandleReceivedMessages()
285316
{
317+
318+
286319
if (P2PHandle == null)
287320
{
288321
return null;
@@ -330,6 +363,21 @@ public ProductUserId HandleReceivedMessages()
330363
}
331364

332365
string message = System.Text.Encoding.UTF8.GetString(data);
366+
// --- Handshake protocol ---
367+
if (message == Request)
368+
{
369+
SendHandshakeAck(peerId);
370+
connectionStates[peerId] = PeerConnectionAppState.FullyConnected;
371+
Debug.Log($"Received handshake request from {peerId}. Sending ack and setting FullyConnected.");
372+
return null;
373+
}
374+
else if (message == Acknowledgement)
375+
{
376+
connectionStates[peerId] = PeerConnectionAppState.FullyConnected;
377+
Debug.Log($"Received handshake ack from {peerId}. Connection is now FullyConnected.");
378+
return null;
379+
}
380+
// --- End handshake ---
333381

334382
if (message.StartsWith("t"))
335383
{
@@ -371,9 +419,11 @@ public ProductUserId HandleReceivedMessages()
371419

372420
return peerId;
373421
}
374-
375-
376-
422+
else if (message == Ping)
423+
{
424+
Debug.Log($"EOS P2PNAT HandleReceivedMessages: received ping from {peerId}, ignoring.");
425+
return null;
426+
}
377427
else
378428
{
379429
Debug.LogErrorFormat("EOS P2PNAT HandleReceivedMessages: error while reading data, code: {0}", result);
@@ -442,11 +492,61 @@ private void OnIncomingConnectionRequest(ref OnIncomingConnectionRequestInfo dat
442492
};
443493

444494
Result result = P2PHandle.AcceptConnection(ref options);
445-
495+
SendHandshakeRequest(data.RemoteUserId);
446496
if (result != Result.Success)
447497
{
448498
Debug.LogErrorFormat("P2p (OnIncomingConnectionRequest): error while accepting connection, code: {0}", result);
449499
}
450500
}
501+
private void SendHandshakeRequest(ProductUserId remoteUserId)
502+
{
503+
SendRaw(remoteUserId, "hreq");
504+
connectionStates[remoteUserId] = PeerConnectionAppState.HandshakePending;
505+
}
506+
507+
private void SendHandshakeAck(ProductUserId remoteUserId)
508+
{
509+
SendRaw(remoteUserId, "hack");
510+
}
511+
512+
private void SendRaw(ProductUserId remoteUserId, string rawMessage)
513+
{
514+
SocketId socketId = new SocketId() { SocketName = "CHAT" };
515+
516+
SendPacketOptions options = new SendPacketOptions()
517+
{
518+
LocalUserId = EOSManager.Instance.GetProductUserId(),
519+
RemoteUserId = remoteUserId,
520+
SocketId = socketId,
521+
AllowDelayedDelivery = true,
522+
Channel = 0,
523+
Reliability = PacketReliability.ReliableOrdered,
524+
Data = new ArraySegment<byte>(Encoding.UTF8.GetBytes(rawMessage))
525+
};
526+
527+
var result = P2PHandle.SendPacket(ref options);
528+
if (result != Result.Success)
529+
{
530+
Debug.LogError($"SendRaw failed: {result}");
531+
}
532+
}
533+
private void OnPeerConnectionEstablished(ref OnPeerConnectionEstablishedInfo info)
534+
{
535+
Debug.Log($"[P2P] Connection established with {info.RemoteUserId}");
536+
537+
if (!connectionStates.ContainsKey(info.RemoteUserId))
538+
{
539+
connectionStates[info.RemoteUserId] = PeerConnectionAppState.IceConnected;
540+
SendHandshakeRequest(info.RemoteUserId);
541+
connectionStates[info.RemoteUserId] = PeerConnectionAppState.HandshakePending;
542+
}
543+
}
544+
public void SendTrigger(ProductUserId peerId)
545+
{
546+
if (!peerId.IsValid()) return;
547+
string trigger = "ping";
548+
SendRaw(peerId, trigger);
549+
}
451550
}
551+
452552
}

Assets/Scripts/P2PNetcodeSample/Networking/EOSTransportManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public class EOSTransportManager : IEOSSubManager
5050
/// Maximum packet byte length
5151
/// </summary>
5252
/// <value><c>1170</c> due to DTLS/SCTP/UDP packet overhead.</value>
53-
public const int MaxPacketSize = P2PInterface.MaxPacketSize;
53+
public const int MaxPacketSize = P2PInterface.MAX_PACKET_SIZE;
5454

5555
/// <summary>
5656
/// Maximum concurrent connections with any individual remote peer.
5757
/// </summary>
5858
/// <value><c>32</c></value>
59-
public const int MaxConnections = P2PInterface.MaxConnections;
59+
public const int MaxConnections = P2PInterface.MAX_CONNECTIONS;
6060

6161
// Connection data, socket name must be unique within an individual remote peer.
6262
public class Connection : IEquatable<Connection>

Assets/Scripts/StandardSamples/Services/TitleStorageService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ private ReadResult OnFileDataReceived(ref ReadFileDataCallbackInfo data)
199199
{
200200
return ReceiveData(data.Filename, data.DataChunk, data.TotalFileSizeBytes) switch
201201
{
202-
FileTransferResult.FailRequest => ReadResult.RrFailrequest,
203-
FileTransferResult.CancelRequest => ReadResult.RrCancelrequest,
204-
FileTransferResult.ContinueReading => ReadResult.RrContinuereading,
202+
FileTransferResult.FailRequest => ReadResult.RrFailRequest,
203+
FileTransferResult.CancelRequest => ReadResult.RrCancelRequest,
204+
FileTransferResult.ContinueReading => ReadResult.RrContinueReading,
205205
_ => throw new ArgumentOutOfRangeException()
206206
};
207207
}

0 commit comments

Comments
 (0)