示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EpicsServerChannel"/> class.
        /// </summary>
        /// <param name="server">
        /// The server.
        /// </param>
        /// <param name="serverId">
        /// The server id.
        /// </param>
        /// <param name="clientId">
        /// The client id.
        /// </param>
        /// <param name="channelName">
        /// The channel name.
        /// </param>
        /// <param name="conn">
        /// The conn.
        /// </param>
        internal EpicsServerChannel(
            EpicsServer server, int serverId, int clientId, string channelName, EpicsServerTCPConnection conn)
        {
            this.NotDisposing = true;
            this.ServerId     = serverId;
            this.ClientId     = clientId;
            this.ChannelName  = channelName;
            this.Server       = server;
            this.Conn         = conn;
            this.Conn.ConnectionStateChanged += this.Conn_ConnectionStateChanged;

            try
            {
                if (channelName.Contains("."))
                {
                    var splitted = channelName.Split('.');
                    this.Record   = this.Server.recordList[splitted[0]];
                    this.Property = (RecordProperty)Enum.Parse(typeof(RecordProperty), splitted[1]);
                }
                else
                {
                    this.Record = this.Server.recordList[this.ChannelName];
                }

                this.Conn.Send(
                    this.Server.Codec.channelCreatedMessage(
                        this.ClientId, this.ServerId, this.Record.TYPE, this.Record.dataCount, this.Access));
            }
            catch (Exception e)
            {
                this.Conn.Send(this.Server.Codec.channelCreationFailMessage(this.ClientId));
                this.Dispose();
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="EpicsServerChannel"/> class.
		/// </summary>
		/// <param name="server">
		/// The server.
		/// </param>
		/// <param name="serverId">
		/// The server id.
		/// </param>
		/// <param name="clientId">
		/// The client id.
		/// </param>
		/// <param name="channelName">
		/// The channel name.
		/// </param>
		/// <param name="conn">
		/// The conn.
		/// </param>
		internal EpicsServerChannel(
			EpicsServer server, int serverId, int clientId, string channelName, EpicsServerTCPConnection conn)
		{
			this.NotDisposing = true;
			this.ServerId = serverId;
			this.ClientId = clientId;
			this.ChannelName = channelName;
			this.Server = server;
			this.Conn = conn;
			this.Conn.ConnectionStateChanged += this.Conn_ConnectionStateChanged;

			try
			{
				if (channelName.Contains("."))
				{
					var splitted = channelName.Split('.');
					this.Record = this.Server.recordList[splitted[0]];
					this.Property = (RecordProperty)Enum.Parse(typeof(RecordProperty), splitted[1]);
				}
				else
				{
					this.Record = this.Server.recordList[this.ChannelName];
				}

				this.Conn.Send(
					this.Server.Codec.channelCreatedMessage(
						this.ClientId, this.ServerId, this.Record.TYPE, this.Record.dataCount, this.Access));
			}
			catch (Exception e)
			{
				this.Conn.Send(this.Server.Codec.channelCreationFailMessage(this.ClientId));
				this.Dispose();
			}
		}