fix(SimpleWebTransport): Implement OnServerConnectedWithAddress

This commit is contained in:
MrGadget 2024-07-20 10:53:06 -04:00
parent 96ddfa040d
commit ce0f70249b
2 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@ namespace Mirror.SimpleWeb
{ {
public class SimpleWebServer public class SimpleWebServer
{ {
public event Action<int> onConnect; public event Action<int, string> onConnect;
public event Action<int> onDisconnect; public event Action<int> onDisconnect;
public event Action<int, ArraySegment<byte>> onData; public event Action<int, ArraySegment<byte>> onData;
public event Action<int, Exception> onError; public event Action<int, Exception> onError;
@ -91,7 +91,7 @@ public void ProcessMessageQueue(MonoBehaviour behaviour)
switch (next.type) switch (next.type)
{ {
case EventType.Connected: case EventType.Connected:
onConnect?.Invoke(next.connId); onConnect?.Invoke(next.connId, GetClientAddress(next.connId));
break; break;
case EventType.Data: case EventType.Data:
onData?.Invoke(next.connId, next.data.ToSegment()); onData?.Invoke(next.connId, next.data.ToSegment());

View File

@ -300,7 +300,7 @@ public override void ServerStart()
SslConfig config = SslConfigLoader.Load(sslEnabled, sslCertJson, sslProtocols); SslConfig config = SslConfigLoader.Load(sslEnabled, sslCertJson, sslProtocols);
server = new SimpleWebServer(serverMaxMsgsPerTick, TcpConfig, maxMessageSize, maxHandshakeSize, config); server = new SimpleWebServer(serverMaxMsgsPerTick, TcpConfig, maxMessageSize, maxHandshakeSize, config);
server.onConnect += OnServerConnected.Invoke; server.onConnect += OnServerConnectedWithAddress.Invoke;
server.onDisconnect += OnServerDisconnected.Invoke; server.onDisconnect += OnServerDisconnected.Invoke;
server.onData += (int connId, ArraySegment<byte> data) => OnServerDataReceived.Invoke(connId, data, Channels.Reliable); server.onData += (int connId, ArraySegment<byte> data) => OnServerDataReceived.Invoke(connId, data, Channels.Reliable);