private void OnServerSelected(rdtServerAddress server)
 {
     if (server != null)
     {
         this.Connect(server);
     }
     else
     {
         this.Disconnect(true);
     }
 }
 private void OnConnectionStatusChanged()
 {
     if ((this.m_client == null) || !this.m_client.IsConnected)
     {
         this.m_currentServer = null;
     }
     this.m_pendingExpandComponent = null;
     this.m_components             = null;
     this.m_expandedCache.Clear();
     this.m_tree.Clear();
     base.Repaint();
 }
 public void Connect(rdtServerAddress address)
 {
     this.Disconnect(true);
     this.m_expandedCache.Clear();
     this.m_pendingExpandComponent = null;
     this.m_components             = null;
     this.m_selected      = null;
     this.m_currentServer = address;
     this.m_client        = new rdtClient();
     this.m_client.Connect(address.IPAddress);
     this.m_client.AddCallback(typeof(rdtTcpMessageGameObjects), new Action <rdtTcpMessage>(this.OnMessageGameObjects));
     this.m_client.AddCallback(typeof(rdtTcpMessageComponents), new Action <rdtTcpMessage>(this.OnMessageGameObjectComponents));
 }
 private void Disconnect([Optional, DefaultParameterValue(true)] bool resetServer)
 {
     if (resetServer)
     {
         this.m_currentServer = null;
     }
     if (this.m_client != null)
     {
         this.m_client.Stop();
     }
     this.m_tree.Clear();
     this.m_selected   = null;
     this.m_components = null;
 }
Beispiel #5
0
        public void Show(rdtServerAddress currentServer)
        {
            GUIContent content  = new GUIContent("Active Player");
            Rect       position = GUILayoutUtility.GetRect(content, EditorStyles.toolbarDropDown);

            GUI.Label(position, content, EditorStyles.toolbarDropDown);
            Event current = Event.current;

            if ((current.isMouse && (current.type == EventType.MouseDown)) && position.Contains(current.mousePosition))
            {
                current.Use();
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("None"), currentServer == null, new GenericMenu.MenuFunction2(this.OnContextMenu), null);
                for (int i = 0; i < this.m_servers.Count; i++)
                {
                    rdtServerAddress userData = this.m_servers[i];
                    menu.AddItem(new GUIContent(userData.ToString()), userData.Equals(currentServer), new GenericMenu.MenuFunction2(this.OnContextMenu), userData);
                }
                menu.DropDown(position);
            }
        }
Beispiel #6
0
        private void OnReceiveHelloCallback(IAsyncResult result)
        {
            try
            {
                rdtUdpMessageHello hello;
                using (MemoryStream stream = new MemoryStream(this.m_udpHello.EndReceive(result, ref this.m_endPoint)))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    hello = formatter.Deserialize(stream) as rdtUdpMessageHello;
                }
                if (hello != null)
                {
                    lock (this.m_lock)
                    {
                        rdtServerAddress item = new rdtServerAddress(this.m_endPoint.Address, hello.m_deviceName, hello.m_deviceType, hello.m_devicePlatform, hello.m_serverVersion);
                        int index             = this.m_servers.IndexOf(item);
                        if (index >= 0)
                        {
                            this.m_servers[index].m_timer = 0.0;
                        }
                        else
                        {
                            rdtDebug.Debug(this, string.Concat(new object[] { "Found a new server ", item.IPAddress, " called ", item.FormattedName, " timestamp=", DateTime.Now.TimeOfDay.TotalSeconds.ToString() }), new object[0]);
                            rdtDebug.Debug(this, "Server has version " + item.m_serverVersion, new object[0]);
                            this.m_servers.Add(item);
                        }
                        goto Label_0160;
                    }
                }
                rdtDebug.Error(this, "Ignoring invalid message", new object[0]);
Label_0160:
                this.m_udpHello.BeginReceive(new AsyncCallback(this.OnReceiveHelloCallback), null);
            }
            catch (ObjectDisposedException)
            {
                rdtDebug.Debug(this, "Hello listener disposed", new object[0]);
                this.Stop();
            }
        }
 private void OnUnityReloadedAssemblies()
 {
     rdtDebug.Debug(this, "OnUnityReloadedAssemblies", new object[0]);
     rdtDebug.s_logLevel = this.m_debug ? rdtDebug.LogLevel.Debug : rdtDebug.LogLevel.Info;
     this.m_running      = true;
     if (this.m_serverEnum != null)
     {
         this.m_serverEnum.Stop();
     }
     this.m_serverEnum = new rdtClientEnumerateServers();
     if (this.m_currentServer != null)
     {
         if (this.m_currentServer.IPAddress == null)
         {
             this.m_currentServer = null;
         }
         else
         {
             this.Connect(this.m_currentServer);
         }
     }
 }