fix(Telepathy): Implement OnServerConnectedWithAddress

This commit is contained in:
MrGadget 2024-07-20 11:05:21 -04:00
parent 237942274d
commit 9dcc6a0953
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ public class Server : Common
{
// events to hook into
// => OnData uses ArraySegment for allocation free receives later
public Action<int> OnConnected;
public Action<int, string> OnConnected;
public Action<int, ArraySegment<byte>> OnData;
public Action<int> OnDisconnected;
@ -388,7 +388,7 @@ public int Tick(int processLimit, Func<bool> checkEnabled = null)
switch (eventType)
{
case EventType.Connected:
OnConnected?.Invoke(connectionId);
OnConnected?.Invoke(connectionId, GetClientAddress(connectionId));
break;
case EventType.Data:
OnData?.Invoke(connectionId, message);

View File

@ -178,7 +178,7 @@ public override void ServerStart()
// system's hook (e.g. statistics OnData) was added is to wrap
// them all in a lambda and always call the latest hook.
// (= lazy call)
server.OnConnected = (connectionId) => OnServerConnected.Invoke(connectionId);
server.OnConnected = (connectionId, remoteClientAddress) => OnServerConnectedWithAddress.Invoke(connectionId, remoteClientAddress);
server.OnData = (connectionId, segment) => OnServerDataReceived.Invoke(connectionId, segment, Channels.Reliable);
server.OnDisconnected = (connectionId) => OnServerDisconnected.Invoke(connectionId);