GithubHelp home page GithubHelp logo

glairedaggers / netcode.io.net Goto Github PK

View Code? Open in Web Editor NEW
254.0 254.0 48.0 7.88 MB

A pure managed C# implementation of the Netcode.IO spec

License: MIT License

C# 100.00%
csharp game-server netcode-io networking udp

netcode.io.net's People

Contributors

glairedaggers avatar gresolio avatar mhjort avatar stellarluminant avatar yome avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netcode.io.net's Issues

Not sure how to get a hold of you

How are you getting your events from the background process to the main thread? I have been having a hard time wrapping my head around this and it looks as though your doing just this.

Server: Send broadcast message.

Have this feature?)
Or should I add RemoteClient in list?
And how I can use ReliableNetcode with this repo, any example please.

p.s. have you any contact? messanger, forum or?

Client disconnect affects other clients on the server

Currently I am testing Netcode.IO.NET from commit f2b060e and I noticed strange thing: sometimes server stops sending keepAlive packets to all clients, and they go to "ConnectionTimedOut" state. This happens when one of the connected clients was disconnected.

As far as I understand, the reason was in EncryptionManager, and this change fixes it (I have not tested completely yet). Have you also faced such issues? Or was it something different?

Connect token expired (Linux)

time

So, I getting error on Linux server when connecting from windows client. What's wrong?

C#factory.GenerateConnectToken(ipEndPoint,30, 10, 1, localClientID, new byte[256])
I see

		/// <summary>
		/// Gets the Unix timestamp of the DateTime object
		/// </summary>
		public static ulong ToUnixTimestamp(this DateTime time)
		{
			return (ulong)Math.Truncate(time.GetTotalSeconds());
		}

But where I should use it?

.NET Standard / Core Support

This is a very interesting library -- I'd like to try it out in my engine. Unfortunately, it doesn't support .NET Core as-is. Any desire to support an alternate configuration, or switch to .NET Standard as the build target? From my experimentation, it seems that the library will compile without any code changes.

Ipv6 support

I have noticed you have the code setup in such a way that if the address is ipv6 it will say the format is invalid. It seems primarily though that the issue comes down to converting the byte[16] from little to big endian. It is treating ::1 as :100

I am unable to connect using the same key on both the client and server

I am trying to get a basic version of this server and client running and it seems that I am unable to do this.

In both my client and server, I have defined:

private static byte[] privateKey = new byte[] { 0x60, 0x6a, 0xbe, 0x6e, 0xc9, 0x19, 0x10, 0xea, 0x9a, 0x65, 0x62, 0xf6, 0x6f, 0x2b, 0x30, 0xe4, 0x43, 0x71, 0xd6, 0x2c, 0xd1, 0x99, 0x27, 0x26, 0x6b, 0x3c, 0x60, 0xf4, 0xb7, 0x15, 0xab, 0xa1 };

The server accepts this just fine and the client continues to throw exceptions while using the TokenFactory to generate a token using this private key.

I have traced it down to AEAD_Chacha20_Poly1305.cs where the line Array.Copy(mac, 0, outBuffer, len, macsize); is executed. I am seeing that outBuffer is a byte array of 1024 length and len is also 1024, which would attempt to copy the 16 bytes from the mac array into outBuffer starting at index 1024 (out of bounds). Any help getting this running would be awesome :). I am excited to get things working!

This snippet of code reliably throws an index out of range exception every time I run it:

var tokenFactory = new TokenFactory(0, new byte[] { 0x60, 0x6a, 0xbe, 0x6e, 0xc9, 0x19, 0x10, 0xea, 0x9a, 0x65, 0x62, 0xf6, 0x6f, 0x2b, 0x30, 0xe4, 0x43, 0x71, 0xd6, 0x2c, 0xd1, 0x99, 0x27, 0x26, 0x6b, 0x3c, 0x60, 0xf4, 0xb7, 0x15, 0xab, 0xa1 }); var token = tokenFactory.GenerateConnectToken(new IPEndPoint[] { new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5566) }, 30, 0, 1, new byte[0]);

Update to Netcode 1.01

A small change was introduced some days ago and Netcode 1.01 was born. The library needs updating.

I might send a PR for this in a few days, I've have only worked on the Go flavor of netcode.

ByteArrayReaderWriter allocating a lot of memory

Hello Alan! Thanks for your work)
Sorry for my english(

Call a WriteBuffer for an array[2048] allocate 10.5 kb memory.
So when i tryied to send a message to a client every client.SendPayload allocated about 30 kb,
30 kb * 30 times/second * 100 players = 87 mb per second.

After changing ByteArrayReaderWriter to Array.copy and creating a broadcast method for a client allocating 1.7 kb or 3.7 kb(idk why, packets is identical). But it still allocating 8 mb per second.
Unity3d 2017, memory check in profiler

Proper C# coding standards

Hi,

I've noticed that the port is using C coding style more than C#. I wanted to ask you if you were willing to let me make a PR about your project related to coding standards.

Things like adding braces around if (), putting classes / interfaces in their own file, creating a bit of a hierarchy as to not have 30 files at the root of the repository, methods starting with an uppercase letter, etc. I didn't want to take the time to do this, make the PR to have it declined because you don't think it's useful.

I've sent you an email but it seems you answer more quickly at github issues XD. It's more of an improvement than an issue but I though here would be the best place to discuss about this (or not).

Good job on the port!

Queue locking strategy error in Client Socket

The queue locking strategy is incorrect for the SocketContext.cs(68-70) call to
if (datagramQueue.Count > 0) { packet = datagramQueue.Dequeue();
In a highly concurrent environment, the queue isn't being locked for the entire transaction and a thread can pull an item off the queue making an empty queue when the datagram dequeue is called and causing a System.InvalidOperationException.
Maybe you should try to convert this to a CAS style operation or move the storage to a tested concurrent data structure.

Failed to connect: Invalid Connect Token

`logLine("Generating token on client...");
TokenFactory factory = new TokenFactory(ProtocolID, privateKey);
byte[] connectToken = factory.GenerateConnectToken(ipEndPoint, 30, 1UL, 1UL, new byte[256]);

    client.Connect(connectToken, () =>
	   { ...

`
So, its bring this message in unity log:

State changed to: -5
UnityEngine.Debug:Log(Object)
UnityNetcodeIO.c__AnonStorey0:<>m__0(ClientState) (at Assets/UnityNetcodeIO/Scripts/Core/NetcodeClient.cs:342)
NetcodeIO.NET.Client:changeState(ClientState)
NetcodeIO.NET.Client:Connect(Byte[])
UnityNetcodeIO.NetcodeClient:Connect(Byte[], Action, Action`1) (at Assets/UnityNetcodeIO/Scripts/Core/NetcodeClient.cs:361)
c__Iterator0:MoveNext() (at Assets/UnityNetcodeIO/Test/Scripts/TestNetcodeIOClient.cs:84)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Add some unit tests?

One of the things I noticed when I was developing the C implementation was that unit tests helped me avoid breaking things.

As the C# implementation starts to mature, can I suggest adding a bunch of unit tests and perhaps a soak test (repeated client/server connects and disconnects), would be a really good way to flush out issues, and also to catch any errors if somebody checks in something.

eg. you can run the unit tests on each checkin via travis.

Has worked great so far for the C implementation.

cheers

  • Glenn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.