void Awake()
    {
        // We abuse unity's matchmaking system to pass around connection info but no match is ever actually joined
        networkMatch = gameObject.AddComponent <NetworkMatch>();

        // Use reflection to get a reference to the private m_ClientId field of NetworkClient
        // We're going to need this later to set the port that client connects from.
        // Even though it's called clientId it is actually the transport level host id that the NetworkClient
        // uses to connect
        clientIDField = typeof(NetworkClient).GetField("m_ClientId", BindingFlags.NonPublic | BindingFlags.Instance);

        natHelper = GetComponent <NATHelper>();
        singleton = this;

        scriptCRCCheck            = false;
        NetworkCRC.scriptCRCCheck = false;

        System.Type type       = typeof(UnityEngine.Networking.NetworkManager);
        var         baseMethod = type.GetMethod("Awake", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

        if (baseMethod != null)
        {
            baseMethod.Invoke(this, null);
        }
    }
예제 #2
0
    void Awake()
    {
        Screen.SetResolution(1020, 768, false);
        random = new System.Random();
        main   = this;
        //networkMatch = gameObject.AddComponent<NetworkMatch>();
        clientIDField = typeof(NetworkClient).GetField("m_ClientId", BindingFlags.NonPublic | BindingFlags.Instance);

        natHelper = GetComponent <NATHelper>();
    }
예제 #3
0
        void AddPortForwardingRules()
        {
            if (nathelper == null)
            {
                return;
            }
            if (!nathelper.GatewayFound)
            {
                return;
            }

            ChangeActivityStatus("Checking Local IP Address...");

            if (string.IsNullOrWhiteSpace(LocalIP))
            {
                ChangeBlurbText("Remote Potato could not get the local IP address, so could not set up your router.");
            }
            else
            {
                ChangeActivityStatus("Checking for router...");
                string txtError = "";

                // Manual rules
                int    lowestStreamPort  = Convert.ToInt32(Settings.Default.SilverlightStreamingPort);
                int    highestStreamPort = lowestStreamPort + Settings.Default.SilverlightStreamingNumberOfPorts - 1;
                string txtManualRules    = String.Format("You need to forward port {0} and ports {1}-{2} to IP address {3} (this computer)\r\n\r\nNeed help? Visit www.portforward.com", Settings.Default.RPPortWithLiveTV.ToString(), lowestStreamPort.ToString(), highestStreamPort.ToString(), LocalIP);

                if (!nathelper.Discover(ref txtError))
                {
                    ChangeBlurbText("Remote Potato could not find a router on your local network - have you disabled UPnP on your router?\r\n\r\n" + txtManualRules);
                }
                else
                {
                    ChangeActivityStatus("Setting up router...");
                    if (nathelper.ForwardRPPorts(LocalIP) == NATHelper.NatHelperReponseCodes.OK)
                    {
                        RPMessageBox.Show("Your router has been automatically set up for Remote Potato.\r\nClick OK to verify the changes.");
                        // TODO:
                        CheckPortForwarding();
                    }
                    else
                    {
                        ChangeBlurbText("Your router could not be automatically set up (see the debug log for more information)\r\n\r\n." + txtManualRules);
                    }
                }

                nathelper = null;
            }

            // Finished - hide mask
            this.Invoke(new Action(HideActivityMask));
        }
예제 #4
0
    void Awake()
    {
        LogFilter.currentLogLevel = LogFilter.Debug;
        natHelper = GetComponent <NATHelper>();

        // Calling this early makes port forwarding go faster
        natHelper.findNatDevice();

        // Connect to Facilitator for punchthrough
        natHelper.StartCoroutine(natHelper.connectToNATFacilitator());

        NetworkTransport.Init();
    }
예제 #5
0
    void Awake()
    {
        // We abuse unity's matchmaking system to pass around connection info but no match is ever actually joined
        networkMatch = gameObject.AddComponent <NetworkMatch>();

        // Use reflection to get a reference to the private m_ClientId field of NetworkClient
        // We're going to need this later to set the port that client connects from.
        // Even though it's called clientId it is actually the transport level host id that the NetworkClient
        // uses to connect
        clientIDField = typeof(NetworkClient).GetField("m_ClientId", BindingFlags.NonPublic | BindingFlags.Instance);

        natHelper = GetComponent <NATHelper>();
    }