Beispiel #1
0
        public StompSource(PacketConverter <T> packetConverter, string serverPortTopic) : base(packetConverter)
        {
            string server = "localhost";
            int    port   = StompConnection.DEFAULT_PORT;
            string topic  = packetConverter.GetDefaultTopic(true);

            PacketSource <T> .ParseServerPortTopic(serverPortTopic, ref server, ref port, ref topic);

            // Create STOMP connection
            stompConnection = null;
            try
            {
                stompConnection = new StompConnection(server, port);
            }
            catch (Exception) {; }

            if (stompConnection != null)
            {
                // Subscribe to a topic
                stompConnection.Subscribe(topic);

                // Create threaded listener and add a message handler
                stompListener = new StompListener(stompConnection);
                stompListener.ReceivedMessage += stompListener_ReceivedMessage;
            }
        }
Beispiel #2
0
 // Forward a packet (can be directly attached to a PacketSource.ReceivedPacket event)
 public void ForwardPacket(PacketSource <T> sender, PacketEventArgs <T> e)
 {
     if (e.Packet != null)
     {
         SendPacket(e.Packet);
     }
 }
Beispiel #3
0
        public OscDest(PacketConverter <T> packetConverter, string serverPortTopic) : base(packetConverter)
        {
            string server = OscReceiver.DEFAULT_INTERFACE;
            int    port   = OscReceiver.DEFAULT_PORT;
            string topic  = packetConverter.GetDefaultTopic(false);

            PacketSource <T> .ParseServerPortTopic(serverPortTopic, ref server, ref port, ref topic);

            oscTransmitter = new OscTransmitter(server, port);
            this.topic     = topic;
        }
Beispiel #4
0
        public StompDest(PacketConverter <T> packetConverter, string serverPortTopic) : base(packetConverter)
        {
            string server = "localhost";
            int    port   = StompConnection.DEFAULT_PORT;
            string topic  = packetConverter.GetDefaultTopic(false);

            PacketSource <T> .ParseServerPortTopic(serverPortTopic, ref server, ref port, ref topic);

            this.topic = topic;

            // Create STOMP connection
            stompConnection = null;
            try
            {
                stompConnection = new StompConnection(server, port);
            }
            catch (Exception) {; }
        }
Beispiel #5
0
        public OscSource(PacketConverter <T> packetConverter, string serverPortTopic) : base(packetConverter)
        {
            string server = OscReceiver.DEFAULT_INTERFACE;
            int    port   = OscReceiver.DEFAULT_PORT;
            string topic  = packetConverter.GetDefaultTopic(false);

            PacketSource <T> .ParseServerPortTopic(serverPortTopic, ref server, ref port, ref topic);

            this.topic = topic;

            // Create OSC connection
            OscReceiver oscReceiver = null;

            try
            {
                oscReceiver = new OscReceiver(port);        // OscReceiver.DEFAULT_PORT
                oscReceiver.ReceivedBundle  += oscReceiver_ReceivedBundle;
                oscReceiver.ReceivedMessage += oscReceiver_ReceivedMessage;
                oscReceiver.Start();
            }
            catch (Exception) {; }
        }
Beispiel #6
0
        private void PacketSource_ReceivedPacket(PacketSource <WaxPacket> sender, PacketEventArgs <WaxPacket> e)
        {
            // If a correctly parsed packet...
            if (e.Packet != null && e.Packet is WaxPacket)
            {
                WaxPacket packet = (WaxPacket)e.Packet;

                //Console.WriteLine("[" + packet.Timestamp + "]");
                //Console.WriteLine(packet.ToString());

                lock (SyncRoot)
                {
                    if (!waxDevices.ContainsKey(packet.DeviceId))
                    {
                        // Create new device
                        waxDevices.Add(packet.DeviceId, new WaxDevice(packet.DeviceId, packet.Timestamp));
                        OnNewDevice(new ManagerEventArgs(waxDevices[packet.DeviceId]));
                    }
                    WaxDevice waxDevice = waxDevices[packet.DeviceId];

                    waxDevice.AddSamples(packet.Samples);

                    // Forward packet to all destinations
                    foreach (PacketDest <WaxPacket> dest in packetDests)
                    {
                        dest.SendPacket(packet);
                    }

                    if (packet != null)
                    {
                        DebugString = packet.ToString();
                    }
                }
                OnReceivedPacket(new ManagerEventArgs(waxDevices[packet.DeviceId], packet));
            }
        }
Beispiel #7
0
 public void SetOutServerPortTopic(string serverPortTopic)
 {
     PacketSource <WaxPacket> .ParseServerPortTopic(serverPortTopic, ref outStompHost, ref outStompPort, ref outStompTopic);
 }
Beispiel #8
0
 public void RemovePacketSource(PacketSource <WaxPacket> source)
 {
     source.ReceivedPacket -= PacketSource_ReceivedPacket;
     packetSources.Remove(source);
 }
Beispiel #9
0
 public void AddPacketSource(PacketSource <WaxPacket> source)
 {
     packetSources.Add(source);
     source.ReceivedPacket += PacketSource_ReceivedPacket;
 }