Code Monkey home page Code Monkey logo

Comments (10)

oddgames-david avatar oddgames-david commented on June 29, 2024

The code below definitely fires on both clients but I don't get any messages after that and when I check netPeer.Connections it's still at "1" which is the connection to the master server.

   case NetIncomingMessageType.NatIntroductionSuccess:
                        Debug.Log("Nat: " + msg.SenderEndPoint.ToString() + " : " + this.GetHashCode());
                        netPeer.Connect(msg.SenderEndPoint);
                        Debug.Log(netPeer.Connections.Count);

from lidgren-network-gen3.

Kittyfisto avatar Kittyfisto commented on June 29, 2024

Did you set NetPeerConfiguration.AcceptIncomingConnections to true for each of those peers? I forgot it when I evaluated this library a few days ago :)

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

Yes, this is my config:

        config.PingInterval = 0.5f;
        config.ConnectionTimeout = 5;
        config.MaximumConnections = 32;
        config.AcceptIncomingConnections = true;
        config.AutoFlushSendQueue = true;
        config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
        config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
        config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

I've had it randomly work twice. I get these each time though:

NAT punch received from 127.0.0.1:57754 we're client, so we've succeeded - token is MatchMaking
NAT punch received from 192.168.1.2:57754 we're host, so we ignore this

I'm guessing the NAT punch is really successful enough.

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

I tried the master server sample and it still doesn't make the connection.

m_client.Connections.Count = 0 in the MSCLIENT after a NatIntroductionSuccess

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

Just to add to this, I'm spawning 2 NetPeers and having them connect to a master server. I'm assuming I can do this and have those two peers make connections to each other.

Any help would be appreciated as I'm still pretty stuck.

from lidgren-network-gen3.

Kittyfisto avatar Kittyfisto commented on June 29, 2024

I'll can try to run the same example when I'm at home - what's your setup? Are the peers and master server on the same computer or different ones?

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

All on same PC.

Master seperate process
Client both in same process as seperate objects

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

Ok, I turned off UPnP on my router and now get the error below, what's interesting is that I turned UPnP back on then used DiscoverKnownPeer after a NatIntroductionSuccess message and connected on a DiscoveryResponse message and I get the same message.

I assume this is a good message and it's actually trying to connect but it has issues adding with the m_handshakes collection, adding to it from a different thread or something.

System.InvalidOperationException: out of sync
at System.Collections.Generic.Dictionary2+Enumerator[System.Net.IPEndPoint,Lidgren.Network.NetConnection].VerifyState () [0x00028] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:912 at System.Collections.Generic.Dictionary2+Enumerator[System.Net.IPEndPoint,Lidgren.Network.NetConnection].MoveNext () [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:835
at Lidgren.Network.NetPeer.Heartbeat () [0x000c0] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\NetPeer.Internal.cs:322
at Lidgren.Network.NetPeer.NetworkLoop () [0x00000] in C:\Users\David\Documents\LidgrenTest\Assets\Lidgren.Network\NetPeer.Internal.cs:208
UnityEngine.Debug:Log(Object)
Lidgren.MatchMaking.c__Iterator0:MoveNext() (at Assets/Lidgren.MM/MatchMaking.cs:164)

from lidgren-network-gen3.

oddgames-david avatar oddgames-david commented on June 29, 2024

Ok, I figured out what I was doing wrong.

My master server was trying to Introduce both sides Introduce(A,B) then Introduce(B,A).

And it was also doubling up the introductions. It connects everytime now, sometimes it produces an out of sync error but it still seems to connect the peers successfully.

I've kept the DiscoverKnownPeer as that seems to work when UPnP is enabled or disabled.

Close this issue.

from lidgren-network-gen3.

Related Issues (20)

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.