Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TryGetPeerById helper method #479

Merged
merged 1 commit into from
Apr 12, 2022
Merged

Add TryGetPeerById helper method #479

merged 1 commit into from
Apr 12, 2022

Conversation

chrisnobrega
Copy link
Contributor

@chrisnobrega chrisnobrega commented Apr 10, 2022

Added TryGet helper method for GetPeerById:

GetPeerById example usage (current):

NetPeer peer = this.netManager.GetPeerById (peerIdentifier);

if (peer != null)
{
    peer.Send (writer, deliveryMethod);
}

TryGetPeerById example usage (new):

if (this.netManager.TryGetPeerById (peerIdentifier, out NetPeer peer))
{
    peer.Send (writer, deliveryMethod);
}

@RevenantX
Copy link
Owner

@chrisnobrega what are you trying to do? This is strange library usage. In most cases you store peers or use Peer.Tag for storing your own info.

@RevenantX RevenantX merged commit 17b48a5 into RevenantX:master Apr 12, 2022
@chrisnobrega
Copy link
Contributor Author

@chrisnobrega what are you trying to do? This is strange library usage. In most cases you store peers or use Peer.Tag for storing your own info.

I will probably roll my own id system, but at the moment I'm using NetPeer ids for identification.

I'm using TryGetPeerById to check if the given peer exists before messaging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants