Exemplo n.º 1
0
        protected void StartNewMemoryChannel(Uri connection)
        {
            MemoryMessageChannel channel = new MemoryMessageChannel(this);

            if (connection.Query != null && connection.Query.StartsWith("?PACKET_SIZE="))
            {
                channel.MAXIMUM_PACKET_SIZE = int.Parse(connection.Query.Substring(13));
            }
            AddChannel(channel);
            if (log.IsDebugEnabled)
            {
                log.Debug("Created Memory Channel.");
            }
        }
Exemplo n.º 2
0
        private void AddChannel(IMessageChannel ch)
        {
            lock (listenList)
            {
                if (ch is NetworkMessageChannel)
                {
                    NetworkMessageChannel channel = ch as NetworkMessageChannel;

                    listenList.Add(channel.InternalSocket);
                    channelsMap.Add(channel.InternalSocket, channel);
                    channelsList.Add(channel);

                    if (channel is TCPMessageChannel)
                    {
                        if (!channelsTypeMap.ContainsKey(ChannelType.TCP))
                        {
                            channelsTypeMap.Add(ChannelType.TCP, new List <IMessageChannel>());
                        }
                        channelsTypeMap[ChannelType.TCP].Add(channel);
                    }
                    else if (channel is UDPMessageChannel)
                    {
                        if (!channelsTypeMap.ContainsKey(ChannelType.UDP))
                        {
                            channelsTypeMap.Add(ChannelType.UDP, new List <IMessageChannel>());
                        }
                        if ((channel as UDPMessageChannel).udpRemoteAddress != null)
                        {
                            channelsTypeMap[ChannelType.UDP].Add(channel);
                        }
                    }

                    else if (channel is MulticastMessageChannel)
                    {
                        if (!channelsTypeMap.ContainsKey(ChannelType.MULTICAST))
                        {
                            channelsTypeMap.Add(ChannelType.MULTICAST, new List <IMessageChannel>());
                        }
                        if ((channel as MulticastMessageChannel).udpMulticastAddress != null)
                        {
                            channelsTypeMap[ChannelType.MULTICAST].Add(channel);
                        }
                    }
                }
                else if (ch is MemoryMessageChannel)
                {
                    MemoryMessageChannel channel = ch as MemoryMessageChannel;
                    if (!channelsTypeMap.ContainsKey(ChannelType.MEMORY))
                    {
                        channelsTypeMap.Add(ChannelType.MEMORY, new List <IMessageChannel>());
                    }
                    channelsTypeMap[ChannelType.MEMORY].Add(channel);
                }
                else
                {
                    throw new Exception("Unknown Message Channel");
                }

                FireChannelAvailable(ch);

                if (listenList.Count == 1)
                {
                    // Signal the calling thread to continue.
                    clientConnected.Set();
                }
            }
        }
Exemplo n.º 3
0
 protected void StartNewMemoryChannel(Uri connection)
 {
     MemoryMessageChannel channel = new MemoryMessageChannel(this);
     if (connection.Query != null && connection.Query.StartsWith("?PACKET_SIZE="))
         channel.MAXIMUM_PACKET_SIZE = int.Parse(connection.Query.Substring(13));
     AddChannel(channel);
     if (log.IsDebugEnabled)
         log.Debug("Created Memory Channel.");
 }