Skip to content

Commit

Permalink
RUDP. impl. StartServerSideConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jul 3, 2024
1 parent c0f234c commit f176661
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rudp/partials/RUDP.ClientTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void InjectBuffer(ref byte[] bytes)

public void StartServerSideConnection(ref Action<bool> callback)
{
throw new NotImplementedException();
_connection.OnServer = callback;
}

private void InitReceiver()
Expand Down
3 changes: 3 additions & 0 deletions src/rudp/partials/utils/RUDP.Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal sealed class Connection
private bool _isOpeningOrClosing;
public Action OnOpen, OnClose;
public Action<string> OnOpenFail;
public Action<bool> OnServer;
public Action<byte[], MessageType> OnData;
public Action<string, byte[], MessageType> OnEvent;
private readonly object _sendIdLocker, _databaseLocker;
Expand Down Expand Up @@ -60,6 +61,7 @@ public Connection(Host host, Socket socket, bool isServer) : this()
public Task Open(int timeout)
{
if (_isOpeningOrClosing || IsOpened) return Task.CompletedTask;
_isOpeningOrClosing = true;

return Task.Run(() =>
{
Expand All @@ -70,6 +72,7 @@ public Task Open(int timeout)
public Task Close()
{
if (_isOpeningOrClosing || !IsOpened) return Task.CompletedTask;
_isOpeningOrClosing = true;

return Task.Run(() =>
{
Expand Down

0 comments on commit f176661

Please sign in to comment.