fix(Telepathy): Implement OnServerConnectedWithAddress

This commit is contained in:
MrGadget 2024-07-20 11:05:21 -04:00
parent ce0f70249b
commit 6de9697e0c
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ public class Server : Common
{ {
// events to hook into // events to hook into
// => OnData uses ArraySegment for allocation free receives later // => 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, ArraySegment<byte>> OnData;
public Action<int> OnDisconnected; public Action<int> OnDisconnected;
@ -388,7 +388,7 @@ public int Tick(int processLimit, Func<bool> checkEnabled = null)
switch (eventType) switch (eventType)
{ {
case EventType.Connected: case EventType.Connected:
OnConnected?.Invoke(connectionId); OnConnected?.Invoke(connectionId, GetClientAddress(connectionId));
break; break;
case EventType.Data: case EventType.Data:
OnData?.Invoke(connectionId, message); 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 // system's hook (e.g. statistics OnData) was added is to wrap
// them all in a lambda and always call the latest hook. // them all in a lambda and always call the latest hook.
// (= lazy call) // (= 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.OnData = (connectionId, segment) => OnServerDataReceived.Invoke(connectionId, segment, Channels.Reliable);
server.OnDisconnected = (connectionId) => OnServerDisconnected.Invoke(connectionId); server.OnDisconnected = (connectionId) => OnServerDisconnected.Invoke(connectionId);