예제 #1
0
        internal static void Find(NetworkSessionType sessionType)
        {
            NetPeerConfiguration peerConfiguration = new NetPeerConfiguration(MonoGamerPeer.applicationIdentifier);

            if (sessionType == NetworkSessionType.PlayerMatch)
            {
                peerConfiguration.EnableMessageType((NetIncomingMessageType)2);
                peerConfiguration.EnableMessageType((NetIncomingMessageType)2048);
            }
            else
            {
                peerConfiguration.EnableMessageType((NetIncomingMessageType)32);
            }
            if (MonoGameNetworkConfiguration.Broadcast != IPAddress.None)
            {
                peerConfiguration.set_BroadcastAddress(MonoGameNetworkConfiguration.Broadcast);
            }
            MonoGamerPeer.netPeer = new NetPeer(peerConfiguration);
            MonoGamerPeer.netPeer.Start();
            if (sessionType == NetworkSessionType.PlayerMatch)
            {
                MonoGamerPeer.GetServerList(MonoGamerPeer.netPeer);
            }
            else
            {
                MonoGamerPeer.netPeer.DiscoverLocalPeers(MonoGamerPeer.port);
            }
            DateTime now = DateTime.Now;

            MonoGamerPeer.discoveryMsgs = new List <NetIncomingMessage>();
            do
            {
                NetIncomingMessage netIncomingMessage;
                while ((netIncomingMessage = MonoGamerPeer.netPeer.ReadMessage()) != null)
                {
                    NetIncomingMessageType messageType = netIncomingMessage.get_MessageType();
                    if (messageType <= 128)
                    {
                        if (messageType != 2)
                        {
                            if (messageType != 64)
                            {
                                if (messageType == 128)
                                {
                                    ;
                                }
                            }
                            else
                            {
                                MonoGamerPeer.discoveryMsgs.Add(netIncomingMessage);
                            }
                        }
                        else if (netIncomingMessage.get_SenderEndpoint().Equals((object)MonoGamerPeer.m_masterServer))
                        {
                            MonoGamerPeer.discoveryMsgs.Add(netIncomingMessage);
                        }
                    }
                    else if (messageType == 256 || messageType == 512 || messageType == 1024)
                    {
                        ;
                    }
                }
            }while ((DateTime.Now - now).Seconds <= 2);
            MonoGamerPeer.netPeer.Shutdown("Find shutting down");
        }