/// <summary> /// Initializes a new instance of the <see cref="EpicsGateWayMonitor"/> class. /// </summary> /// <param name="channel"> /// The channel. /// </param> /// <param name="gateWay"> /// The gate way. /// </param> /// <param name="key"> /// The key. /// </param> /// <param name="header"> /// The header. /// </param> /// <param name="payload"> /// The payload. /// </param> internal EpicsGateWayMonitor( EpicsGateWayIocChannel channel, EpicsGateWay gateWay, long key, byte[] header, byte[] payload) { this.Channel = channel; this.GateWay = gateWay; this.Key = key; this.SubscriptionId = this.GateWay.RegisterNewMonitor(this); this.Channel.Connection.Send( this.GateWay.ConnectorCodec.createSubscriptionMessage(header, payload, this.SubscriptionId, this.Channel.IocChanId)); }
/// <summary> /// Initializes a new instance of the <see cref="EpicsUDPGWConnection"/> class. /// </summary> /// <param name="gateWay"> /// The gate way. /// </param> /// <param name="Codec"> /// The codec. /// </param> public EpicsUDPGWConnection(EpicsGateWay gateWay, EpicsCodec Codec) { this.GateWay = gateWay; this.UDPSocket.SendBufferSize = this.GateWay.Config.UDPBufferSize; this.UDPSocket.ReceiveBufferSize = this.GateWay.Config.UDPBufferSize; this.wrapTargetList(this.GateWay.Config.ServerList.getStringList()); gateWay.Config.ConfigChanged += this.Config_ConfigChanged; this.codec = Codec; }
/// <summary> /// Initializes a new instance of the <see cref="EpicsGateWayIocChannel"/> class. /// </summary> /// <param name="channelName"> /// The channel name. /// </param> /// <param name="gwIocId"> /// The gw ioc id. /// </param> /// <param name="gw"> /// The gw. /// </param> /// <param name="udpRequester"> /// The udp requester. /// </param> /// <param name="clientChanId"> /// The client chan id. /// </param> internal EpicsGateWayIocChannel( string channelName, uint gwIocId, EpicsGateWay gw, EndPoint udpRequester, uint clientChanId) { this.CreatedAt = DateTime.Now; this.GateWay = gw; this.GWIocChanId = gwIocId; this.ChannelName = channelName; this.UdpRequester = udpRequester; this.ClientChanId = clientChanId; this.GateWay.Statistic.OpenServerChannels++; }
/// <summary> /// Initializes a new instance of the <see cref="EpicsTCPGWConnection"/> class. /// </summary> /// <param name="TCPSocket"> /// The tcp socket. /// </param> /// <param name="gw"> /// The gw. /// </param> internal EpicsTCPGWConnection(Socket TCPSocket, EpicsGateWay gw) : base(TCPSocket) { this.GateWay = gw; this.codec = this.GateWay.ReceiverCodec; this.clientConnection = true; this.GateWay.Statistic.ClientConnected++; this.remoteKey = TCPSocket.RemoteEndPoint.ToString(); TCPSocket.ReceiveBufferSize = this.GateWay.Config.TCPBufferSize; TCPSocket.SendBufferSize = this.GateWay.Config.TCPBufferSize; }
/// <summary> /// Initializes a new instance of the <see cref="EpicsTCPGWConnection"/> class. /// </summary> /// <param name="ipe"> /// The ipe. /// </param> /// <param name="gw"> /// The gw. /// </param> internal EpicsTCPGWConnection(IPEndPoint ipe, EpicsGateWay gw) : base(ipe) { this.GateWay = gw; this.codec = this.GateWay.ConnectorCodec; this.GateWay.Statistic.ServerConnected++; this.TCPSocket.ReceiveBufferSize = this.GateWay.Config.TCPBufferSize; this.TCPSocket.SendBufferSize = this.GateWay.Config.TCPBufferSize; this.Send(EpicsCodec.CTCPGreet); this.remoteKey = ipe.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="EpicsGateWayReceiverCodec"/> class. /// </summary> /// <param name="gw"> /// The gw. /// </param> internal EpicsGateWayReceiverCodec(EpicsGateWay gw) { this.GateWay = gw; }
/// <summary> /// Initializes a new instance of the <see cref="EpicsGateWayClientChannel"/> class. /// </summary> /// <param name="gateWay"> /// The gate way. /// </param> /// <param name="clientChanId"> /// The client chan id. /// </param> /// <param name="channelName"> /// The channel name. /// </param> /// <param name="ipAddress"> /// The ip address. /// </param> /// <param name="gWClientChanId"> /// The g w client chan id. /// </param> internal EpicsGateWayClientChannel( EpicsGateWay gateWay, uint clientChanId, string channelName, EndPoint ipAddress, uint gWClientChanId) { this.GateWay = gateWay; this.IpAddress = ipAddress.ToString(); this.ClientChanId = clientChanId; this.GWClientChanId = gWClientChanId; this.ChannelName = channelName; try { this.Conn = this.GateWay.TCPConnections[this.IpAddress]; } catch (Exception e) { Trace.Write("ITCP Connection for Channel was closed before Channel was established (IP: " + this.IpAddress + ")"); this.Dispose(); return; } try { this.Channel = this.GateWay.ChannelListIocName[channelName]; } catch (Exception e) { // if it was not yet established, give it a second to find, if not it's to slow and it shall be found next time var timeout = new TimeSpan(0, 0, 1); var wtch = new Stopwatch(); wtch.Start(); while (this.GateWay.ChannelSearchNameWait.ContainsKey(channelName)) { Thread.Sleep(0); if (wtch.Elapsed > timeout) { break; } } wtch.Stop(); try { this.Channel = this.GateWay.ChannelListIocName[channelName]; } catch { Trace.Write("IChannel creation to fast, finding to slow."); this.Conn.Send(this.GateWay.ReceiverCodec.channelCreationFailMessage(this.ClientChanId)); this.Dispose(); return; } } this.IpAddressEndpoint = ipAddress; var calcRights = this.GateWay.Rules.GetAccessRights(this.IpAddressEndpoint, this.Conn.Username, this.ChannelName); if (calcRights < this.Channel.AccessRights) { this.Access = calcRights; } else { this.Access = this.Channel.AccessRights; } gateWay.Rules.RulesChanged += this.Rules_RulesChanged; this.Conn.ConnectionStateChanged += this.EpicsGateWayClientChannel_ConnectionStateChanged; this.Conn.Send( this.GateWay.ReceiverCodec.channelCreatedMessage( this.ClientChanId, this.GWClientChanId, this.Access, this.Channel.CreateMessageAnswer)); this.GateWay.Statistic.OpenClientChannels++; }
/// <summary> /// Initializes a new instance of the <see cref="EpicsGateWayConnectorCodec"/> class. /// </summary> /// <param name="gw"> /// The gw. /// </param> internal EpicsGateWayConnectorCodec(EpicsGateWay gw) { this.GateWay = gw; }