Ejemplo n.º 1
0
        void HandleServerChanges()
        {
            if (OscServer.PortToServer.Count > m_PreviousServerCount)
            {
                m_Server = OscServer.PortToServer.First().Value;
                m_Server.AddMonitorCallback(Monitor);
                m_ServerLabel         = $"Messages being received on port {m_Server.Port}";
                m_ShowNoServerWarning = false;

                if (!Application.isPlaying)
                {
                    EditorApplication.update += Update;
                }
            }
            else if (OscServer.PortToServer.Count < m_PreviousServerCount)
            {
                m_Server?.RemoveMonitorCallback(Monitor);
                m_Server              = null;
                m_ServerLabel         = null;
                m_ShowNoServerWarning = true;
                m_PreviousServerCount = OscServer.PortToServer.Count;

                if (!Application.isPlaying)
                {
                    EditorApplication.update -= Update;
                }
            }

            m_PreviousServerCount = OscServer.PortToServer.Count;
        }
Ejemplo n.º 2
0
 void OnEnable()
 {
     // OnEnable gets called twice when you enter play mode, but we just want one server instance
     if (m_Started)
     {
         return;
     }
     m_Server  = OscServer.GetOrCreate(m_Port);
     m_Started = true;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get an existing OSC server on the given port, or create one if it doesn't exist.
        /// </summary>
        /// <param name="port">The port to listen for incoming message on</param>
        /// <returns></returns>
        public static OscServer GetOrCreate(int port)
        {
            OscServer server;

            if (!PortToServer.TryGetValue(port, out server))
            {
                server             = new OscServer(port);
                PortToServer[port] = server;
            }
            return(server);
        }
Ejemplo n.º 4
0
 void HandleServerChanges()
 {
     if (m_PreviousServerCount == 0 && OscServer.PortToServer.Count > 0)
     {
         m_Server = OscServer.PortToServer.First().Value;
         m_Server.AddMonitorCallback(Monitor);
         m_PreviousServerCount = OscServer.PortToServer.Count;
         m_ServerLabel         = $"Messages being received on port {m_Server.Port}";
         m_ShowNoServerWarning = false;
     }
     else if (m_PreviousServerCount > 0 && OscServer.PortToServer.Count == 0)
     {
         m_Server?.RemoveMonitorCallback(Monitor);
         m_Server              = null;
         m_ServerLabel         = null;
         m_ShowNoServerWarning = true;
         m_PreviousServerCount = OscServer.PortToServer.Count;
     }
 }
Ejemplo n.º 5
0
 void OnEnable()
 {
     m_ActiveQueueBuffer = m_ToQueue;
     m_Server            = OscServer.PortToServer.First().Value;
     m_Server.AddMonitorCallback(Monitor);
 }