moien007 / enet.managed Goto Github PK
View Code? Open in Web Editor NEWA managed wrapper for ENet UDP Networking Library written in C#
License: MIT License
A managed wrapper for ENet UDP Networking Library written in C#
License: MIT License
Is there any option for fetching the last ping time? I see the Ping method has been exposed but no way to actually access the value of a Peer's ping.
if you try to access ENetHost.PeerList
it'll cause a crash.
I've tried to filter out non connected peers, yet still causes a crash.
it works for the first few peers i don't have any numbers though.
Sample code:
ManagedENet.Startup();
var ip = IPEndPoint.Parse("127.0.0.1:27015");
var _host = new ENetHost(ip, 1024, 10);
_host.ChecksumWithCRC32();
_host.CompressWithRangeCoder();
while (true)
{
var ev = _host.Service(TimeSpan.FromSeconds(1));
switch (ev.Type)
{
// Do stuff...
}
foreach (var peer in _host.PeerList.Where(s => s.State == ENetPeerState.Connected)) // Crash
{
// Handle pump data onto peers
}
}
Exception:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ENet.Managed.ENetPeer.get_State()
at Sample.Program+<>c.<Main>b__0_0(ENet.Managed.ENetPeer)
at System.Linq.Enumerable+WhereEnumerableIterator`1[[ENet.Managed.ENetPeer, ENet.Managed, Version=4.2.5.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Sample.Program.Main(System.String[])
Version: 4.2.5
.NET Version: .NET Core 3.1
OS: Windows 10 2004 x86_64
ENet.Managed/ENet.Managed/LibENet.cs
Line 258 in 9c840f1
This line only checks against windows binaries resources which is will throw on linux, Platform.Current.GetENetBinaryBytes()
has to be used instead.
It causes a crash and does not leave useful information, just that the "Service thread" has stopped.
Hello im trying to use this on linux and im getting this error while trying to connect
Segmentation fault (core dumped) while in windows it work any idea?
ENetAsyncHost stops immediately after it's started. I believe the problem is in ENetAsyncHost.RunServiceLoop
:
ENet.Managed/src/ENet.Managed/Async/ENetAsyncHost.cs
Lines 490 to 518 in c1cc588
The condition in the outer while
loop should be !m_Stop
because m_Stop != false
is only true when m_Stop
is true, so when the host is shutting down, which means the service thread stops immediately.
I can prove my hypothesis by manually setting m_Stop
to true with some hacky reflection at runtime before starting the host:
var field = typeof(ENetAsyncHost).GetField("m_Stop", BindingFlags.NonPublic | BindingFlags.Instance);
field.SetValue(myAsyncHost, true);
Is this wrapper of ENet thread-safe as I make use of its StartServiceThread function which basically explains what I am talking about.
Do I need any further code to deal with thread safety or did the wrapper have it included/implemented?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.