Comments (1)
Hello @cnbryan
what would you like to do?
Here are a few possibilities of finding clients(links):
You can save the link on a new connection in your client object
public static void OnNewLink(object p, LinkEventArgs e)
{
MyClient client = new MyClient(){ link = e.lnk};
client.link
}
and attach your object to the link
e.lnk.AttachedID = client.Id;
e.lnk.AttachedObject = client;
so you can access your object directly over the link on a new packet, here you do not need to search
static void OnSystemPacket(object p, PacketEventArgs e)
{
MyClient c = (MyClient)e.lnk.AttachedObject;
If(c != null){
//…
};
}
the last possibility is, if you want to send data to other clients:
with IDPool you can generate unique Ids
static IDPool myIdPool = new IDPool(100000);
Then you can store the unique Id in the link
e.lnk.AttachedID = myIdPool.GetFreeID(); // on new link
myIdPool.DisposeID(e.lnk.AttachedID); // on disconnecting link
with this unique Id you can store your links in a hashtable or a fast array
static Hashtable Linktable = new Hashtable();
Linktable.Add(e.lnk.AttachedID, e.lnk);
when you receive a packet for another client you can access the client with the id.
(A better way is, to access your client object directly with the unique Id)
// this packet is from client one for client two
Link myLink = (Link)Linktable[e.pak.ObjectID];
MyClient c = (MyClient)myLink.AttachedObject; // and get your object from the link
Best regards
from vaser.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vaser.