/// <summary>
 ///     �ͻ������Ӵ��������ṩ����صĻ�������
 /// </summary>
 /// <param name="channel">�ͻ�������</param>
 /// <param name="transactionManager">���������</param>
 public ThriftConnectionAgent(IMessageTransportChannel<ThriftMessage> channel, ThriftMessageTransactionManager transactionManager)
 {
     if (channel == null) throw new ArgumentNullException("channel");
     if (!channel.IsConnected) throw new ArgumentException("Cannot wrap this msg channel, because current msg channel has been disconnected!");
     if (transactionManager == null) throw new ArgumentNullException("transactionManager");
     _sequenceId = 0;
     _channel = channel;
     _transactionManager = transactionManager;
     _channel.Disconnected += ChannelDisconnected;
     _channel.ReceivedMessage += ChannelReceivedMessage;
 }
 /// <summary>
 ///     ����һ���µ����Ӵ�����
 /// </summary>
 /// <param name="iep">Զ���ս���ַ</param>
 /// <param name="protocolStack">Э��ջ</param>
 /// <param name="transactionManager">���������</param>
 /// <returns>����޷����ӵ�Զ�̵�ַ���򷵻�null.</returns>
 public static IThriftConnectionAgent Create(IPEndPoint iep, IProtocolStack<ThriftMessage> protocolStack, ThriftMessageTransactionManager transactionManager)
 {
     if (iep == null) throw new ArgumentNullException("iep");
     if (protocolStack == null) throw new ArgumentNullException("protocolStack");
     if (transactionManager == null) throw new ArgumentNullException("transactionManager");
     ITransportChannel transportChannel = new TcpTransportChannel(iep);
     transportChannel.Connect();
     if (!transportChannel.IsConnected) return null;
     IMessageTransportChannel<ThriftMessage> msgChannel = new MessageTransportChannel<ThriftMessage>((IRawTransportChannel)transportChannel, protocolStack, new ThriftProtocolSegmentDataParser((ThriftProtocolStack) protocolStack));
     return new ThriftConnectionAgent(msgChannel, transactionManager);
 }
 /// <summary>
 ///     获取具有指定标示的连接代理器,如果具有该条件的代理器不存在,则会创建一个新的代理器
 /// </summary>
 /// <param name="key">连接标示</param>
 /// <param name="roleId">服务角色编号</param>
 /// <param name="protocolStack">连接所承载的协议栈</param>
 /// <param name="transactionManager">事务管理器</param>
 /// <returns>如果返回null, 则表示当前无法连接到目标远程终结点地址</returns>
 public IThriftConnectionAgent GetChannel(string key, string roleId, IProtocolStack<ThriftMessage> protocolStack, ThriftMessageTransactionManager transactionManager)
 {
     string fullKey = string.Format("{0}#{1}", roleId, key);
     return base.GetChannel(key, fullKey, protocolStack, transactionManager);
 }