Beispiel #1
0
 public void Receive(string sendName, MessageReceiveCallback messageReceiver, bool asynchronous = false)
 {
     if (!sendNameMessageReceiverDict.ContainsKey(sendName))
     {
         LibPD.Subscribe(sendName);
         sendNameMessageReceiverDict[sendName] = new List <PureDataMessageReceiver>();
     }
     sendNameMessageReceiverDict[sendName].Add(new PureDataMessageReceiver(sendName, messageReceiver, asynchronous, pureData));
 }
Beispiel #2
0
 public void Release(MessageReceiveCallback messageCallback)
 {
     foreach (List <PureDataMessageReceiver> messageReceivers in sendNameMessageReceiverDict.Values)
     {
         for (int i = messageReceivers.Count - 1; i >= 0; i--)
         {
             if (messageReceivers[i].messageReceiver == messageCallback)
             {
                 Release(messageReceivers[i]);
             }
         }
     }
 }
Beispiel #3
0
        public void Start(MessageReceiveCallback onMessageReceiveCallback)
        {
            if (messageThread != null)
            {
                throw new Exception("message loop already running");
            }

            this.onMessageReceiveCallback = onMessageReceiveCallback;

            Console.WriteLine("listening for clients...");
            handler = listener.Accept();
            Console.WriteLine("connection established.");

            messageThread = new Thread(MessageLoop);
            messageThread.Start();
        }
Beispiel #4
0
 /// <summary>
 /// Unsubscribes a delegate so that it stops receiving messages from Pure Data.
 /// </summary>
 /// <param name="messageReceiver">The subscribed delegate that will stop receiving messages.</param>
 public static void Release(MessageReceiveCallback messageReceiver)
 {
     instance.communicator.Release(messageReceiver);
 }
Beispiel #5
0
 /// <summary>
 /// Subscribes a delegate so that it receives messages from all <c>[send <paramref name="sendName"/>]</c> in Pure Data.
 /// </summary>
 /// <param name="sendName">The name of the sender from which the messages will be received.</param>
 /// <param name="messageReceiver">The delegate that will receive the messages.</param>
 /// <param name="asynchronous">If true, the messages will be received as soon as they are sent by Pure Data, otherwise they will be received on the next Unity Update, FixedUpdate or LateUpdate.</param>
 public static void Receive(string sendName, MessageReceiveCallback messageReceiver, bool asynchronous = false)
 {
     instance.communicator.Receive(sendName, messageReceiver, asynchronous);
 }
 public PureDataMessageReceiver(string sendName, MessageReceiveCallback messageReceiver, bool asynchronous, PureData pureData)
     : base(sendName, asynchronous, pureData)
 {
     this.messageReceiver = messageReceiver;
 }
		public PureDataMessageReceiver(string sendName, MessageReceiveCallback messageReceiver, bool asynchronous, PureData pureData)
			: base(sendName, asynchronous, pureData) {
			
			this.messageReceiver = messageReceiver;
		}