Beispiel #1
0
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="ccrParameter">Ccr运行参数</param>
		public DataReceiver(CcrParameter ccrParameter)
		{
			Debug.Assert(ccrParameter != null);

			m_queueReceived = QueueFactory<AddressDataPair>.CreateQueue(
				ccrParameter.ThreadCount,
				"Communication",
				OnDataReceived,
				(TaskExecutionPolicy)ccrParameter.TaskPolicy,
				ccrParameter.RateOrDepth);
		}
Beispiel #2
0
        /// <summary>
		/// 创建接收器
		/// </summary>
		/// <param name="url">url地址,诸如:udp://127.0.0.1:9999</param>
		/// <param name="ccrParameter">Ccr运行参数</param>
		/// <param name="bufferPoolParameter">缓冲池参数</param>
		/// <param name="contained">是否由通信器统一管理</param>
		/// <returns>数据接收器。如果是null,则表示数据接收器已经存在</returns>
		/// <exception cref="System.ArgumentException">当不能创建时,抛出异常</exception>
		/// <exception cref="System.Net.Sockets.SocketException">当不能创建时,抛出异常</exception>
		public DataReceiver CreateReceiver(string url, CcrParameter ccrParameter, BufferPoolParameter bufferPoolParameter, bool contained)
		{
			DataReceiver receiver = null;

			PipelineAddress sa = PipelineAddress.Parse(url);
			switch (sa.CommuncationType)
			{
				case CommuncationType.Tcp:
					receiver = new TcpSharpReceiver((IPEndPoint)sa.Address, ccrParameter, bufferPoolParameter);
					break;
				case CommuncationType.Udp:
				case CommuncationType.Udps:
					receiver = new UdpSharpReceiver((IPEndPoint)sa.Address, ccrParameter, bufferPoolParameter);
					break;
				case CommuncationType.Udpa:
					receiver = new UdpReceiver((IPEndPoint)sa.Address, ccrParameter);
					break;
				case CommuncationType.Msmq:
					receiver = new MsmqReceiver((string)sa.Address, ccrParameter);
					break;
				case CommuncationType.Sms:
					throw new ArgumentException(String.Format("NotSupportedCommunication:{0}", url));
				case CommuncationType.Http:
					throw new ArgumentException(String.Format("NotSupportedCommunication:{0}", url));
				case CommuncationType.SharedMemory:
					receiver = new ShareMemoryReceiver((ShareMemoryEndPoint)sa.Address, ccrParameter);
					break;
				case CommuncationType.SharedRegion:
					break;
				case CommuncationType.Ftp:
					break;
				case CommuncationType.Unknown:
					throw new ArgumentException(String.Format("NotSupportedCommunication:{0}", url));
				default:
					throw new ArgumentException(String.Format("Illegal url: {0}", url));
			}

			if (receiver != null && contained)
			{
				m_receivers.Add(receiver.LocalEndPoint, receiver);
			}

			return receiver;
		}
Beispiel #3
0
        public DataReceiver CreateReceiver(string listenUri, string baseAddress, CcrParameter ccrParameter, BufferPoolParameter bufferPoolParameter)
        {
            DataReceiver receiver = CreateReceiver(listenUri, ccrParameter, bufferPoolParameter, false);
			if (receiver != null)
			{
				m_receivers.Add(baseAddress, receiver);
			}

            return receiver;
        }
Beispiel #4
0
		/// <summary>
		/// 创建接收器
		/// </summary>
		/// <param name="url">url地址,诸如:udp://127.0.0.1:9999</param>
		/// <param name="ccrParameter">Ccr运行参数</param>
		/// <param name="bufferPoolParameter">缓冲池参数</param>
		/// <returns>数据接收器。如果是null,则表示数据接收器已经存在</returns>
		/// <exception cref="System.ArgumentException">当不能创建时,抛出异常</exception>
		/// <exception cref="System.Net.Sockets.SocketException">当不能创建时,抛出异常</exception>
		public DataReceiver CreateReceiver(string url, CcrParameter ccrParameter, BufferPoolParameter bufferPoolParameter)
		{
			return CreateReceiver(url, ccrParameter, bufferPoolParameter, true);
		}
Beispiel #5
0
		/// <summary>
		/// 创建接收器
		/// </summary>
		/// <param name="url">url地址,诸如:udp://127.0.0.1:9999</param>
		/// <param name="ccrParameter">Ccr运行参数</param>
		/// <returns>数据接收器。如果是null,则表示数据接收器已经存在</returns>
		/// <exception cref="System.ArgumentException">当不能创建时,抛出异常</exception>
		/// <exception cref="System.Net.Sockets.SocketException">当不能创建时,抛出异常</exception>
		public DataReceiver CreateReceiver(string url, CcrParameter ccrParameter)
		{
			return CreateReceiver(url, ccrParameter, null);
		}