Пример #1
0
        public override void RecieveTangoRoomInfo(string data)
        {
            var dataArray = data.Split('~'); //parse data

            UnityEngine.Debug.Log("RecievedTangoInfo " + dataArray.Length);
            List <String> RoomNames = new List <string>();

            if (dataArray.Length > 1)
            {
                for (int i = 0; i < dataArray.Length; i += 2)
                {
                    TangoDatabase.TangoData T = new TangoDatabase.TangoData();
                    T.name = dataArray[i];
                    RoomNames.Add(T.name);
                    T.size = System.Int32.Parse(dataArray[i + 1]);

                    UnityEngine.Debug.Log(i + " " + T.name + " " + T.size);
                    if (!TangoDatabase.LookUpName(T.name))
                    {
                        TangoRoomStack.Push(T); //if room does not already exist, add to stack
                    }
                }
            }
            else
            {
                RoomNames.Add(" ");
            }

            TangoDatabase.CompareList(RoomNames); //delete any rooms missing
        }
Пример #2
0
        /// <summary>
        /// Listens for the TCP connection from the master client and recieves the room mesh
        /// </summary>
        /// <param name="T"></param>
        void RecieveTangoMeshThread(TangoDatabase.TangoData T)
        {
            TcpListener receiveTcpListener = new TcpListener(IPAddress.Any, (Port + 1));

            try
            {
                receiveTcpListener.Start();
            }
            catch (SocketException)
            {
                UnityEngine.Debug.Log("Error");
                _ThreadFinished = true;
                Thread.CurrentThread.Abort();
            }

            var client = receiveTcpListener.AcceptTcpClient();

            using (var stream = client.GetStream())
            {
                byte[] parentData = new byte[4];
                byte[] data       = new byte[T.size];

                UnityEngine.Debug.Log("Start receiving mesh " + data.Length);
                using (MemoryStream ms = new MemoryStream())
                {
                    //Get the parent of the mesh
                    stream.Read(parentData, 0, 4);
                    int parentID = BitConverter.ToInt32(parentData, 0);

                    int numBytesRead;
                    while ((numBytesRead = stream.Read(data, 0, data.Length)) > 0)
                    {
                        ms.Write(data, 0, numBytesRead);
                    }
                    UnityEngine.Debug.Log("finish receiving mesh: size = " + ms.Length);
                    TangoDatabase.UpdateMesh(ms.ToArray(), T.name, parentID);
                }
            }

            client.Close();

            receiveTcpListener.Stop();

            _ThreadFinished = true;

            UnityEngine.Debug.Log("Join Thread");
            Thread.CurrentThread.Join();
        }
Пример #3
0
        /// <summary>
        /// Creates a thread to recieve a TangoMesh based on the mesh currently at the top of the stack
        /// Sends a RPC call to the masterclient with the name of the room
        /// </summary>
        public virtual void ReceiveTangoMeshStack()
        {
            TangoDatabase.TangoData T = TangoRoomStack.Pop();

            if (!TangoDatabase.LookUpName(T.name))
            {
                _ThreadFinished = false;
                Thread Th = new Thread(() => RecieveTangoMeshThread(T));
                Th.IsBackground = true;
                Th.Start();
                threads.Add(Th);


                photonView.RPC("SendTangoMeshByName", PhotonTargets.MasterClient, GetLocalIpAddress() + "~" + (Port + 1) + "~" + T.name);
            }
        }