Esempio n. 1
0
        //!
        //! Init the sever adpater for receiving a scene
        //! This will check the IP, (re)start receiver thread, request progress state
        //!
        public void initServerAdapterTransfer()
        {
            if (!ipAdressFormat.IsMatch(VPETSettings.Instance.serverIP))
            {
                deactivatePublish       = true;
                deactivateReceive       = true;
                deactivatePublishKatana = true;
            }

            // clear previous scene
            sceneLoader.ResetScene();

            // if (!ipAdressFormat.IsMatch(VPETSettings.Instance.katanaIP)) deactivatePublishKatana = true;

            katanaTemplates = GameObject.Find("KatanaTemplates").GetComponent <KatanaTemplates>();


            isRunning = true;


            //bind Threads to methods & start them
            if (!deactivateReceive && receiverThread == null)
            {
                receiverThread = new Thread(new ThreadStart(listener));
                receiverThread.Start();
            }
            if (!deactivatePublish && senderThread == null)
            {
                senderThread = new Thread(new ThreadStart(publisher));
                senderThread.Start();
            }
            if (!deactivatePublishKatana && katanaSenderThread == null)
            {
                katanaSenderThread = new Thread(new ThreadStart(sendKatana));
                katanaSenderThread.Start();
            }

            if (VPETSettings.Instance.doLoadFromResource)
            {
                sceneReceiverThread = null;
                sceneReceiverResource();
            }
            else
            {
                if (sceneReceiverThread != null)
                {
                    sceneReceiverThread.Abort();
                    sceneReceiverThread = null;
                }

                sceneReceiverThread = new Thread(new ThreadStart(sceneReceiver));
                sceneReceiverThread.Start();
            }
        }
Esempio n. 2
0
        //!
        //! Init the sever adpater for receiving a scene
        //! This will check the IP, (re)start receiver thread, request progress state
        //!
        public void initServerAdapterTransfer()
        {
            if (!ipAdressFormat.IsMatch(VPETSettings.Instance.serverIP))
            {
                deactivatePublish       = true;
                deactivateReceive       = true;
                deactivatePublishKatana = true;
            }

            // clear previous scene
            sceneLoader.ResetScene();

            // if (!ipAdressFormat.IsMatch(VPETSettings.Instance.katanaIP)) deactivatePublishKatana = true;

            //bind Threads to methods & start them
            if (!deactivateReceive && receiverThread == null)
            {
                receiverThread = new Thread(new ThreadStart(listener));
                receiverThread.Start();
                isRunning = true;
            }
            if (!deactivatePublish)
            {
                // create thread for all registered sender
                foreach (ObjectSender sender in  objectSenderList)
                {
                    sender.SetTarget(VPETSettings.Instance.serverIP, "5557");
                    Thread _thread = new Thread(new ThreadStart(sender.Publisher));
                    _thread.Start();
                    if (!senderThreadList.Contains(_thread))
                    {
                        senderThreadList.Add(_thread);
                    }
                    sender.IsRunning = true;
                }
            }

            if (VPETSettings.Instance.doLoadFromResource)
            {
                sceneReceiverThread = null;
                sceneReceiverResource();
            }
            else
            {
                if (sceneReceiverThread != null)
                {
                    sceneReceiverThread.Abort();
                    sceneReceiverThread = null;
                }

                sceneReceiverThread = new Thread(new ThreadStart(sceneReceiver));
                sceneReceiverThread.Start();
            }
        }