/**
         * Receives some data from a client once a connection
         * has been established. This will block until the client
         * calls <code>request(Object)</code> but by establishing
         * a connection.
         *
         * @return the <code>Object</code> sent by the client.
         */
        public Object request() //throws IllegalStateException
        {
            if (currentServerState == SERVER_STATE_RECEIVED)
            {
                throw new InvalidOperationException("Cannot call request() twice on ConnectionServer without replying to the client first.");
            }
            ConnectionClientMessage msg = (ConnectionClientMessage)currentInputChannel.read();

            if (currentServerState == SERVER_STATE_CLOSED)
            {
                if (msg is ConnectionClientOpenMessage)
                {
                    //channel to use to reply to client
                    toClient = ((ConnectionClientOpenMessage)msg).replyChannel;
                    setAltingChannel(furtherRequestIn);
                    currentInputChannel = furtherRequestIn;

                    //create a new msg for connection established
                    //don't know if client implementation will have finished with
                    //message after connection closed
                    this.msg = new ConnectionServerMessage();
                }
                else
                {
                    throw new InvalidOperationException("Invalid message received from client");
                }
            }
            currentServerState = SERVER_STATE_RECEIVED;
            return(msg.data);
        }
 public PhilosopherBehaviour(ChannelOutput service, ChannelInput deliver, ChannelOutput toConsole, int id)
 {
     this.service   = service;
     this.deliver   = deliver;
     this.toConsole = toConsole;
     this.id        = id;
 }
Пример #3
0
 public SingleProcess(ChannelInput input, ChannelOutput output, int n)
 {
     this.input  = input;
     this.output = output;
     this.n      = n;
     //this.timeout = timeout;
 }
        /**
         * Sends some data back to the client after a request
         * has been received. The closed parameter indicates whether or not
         * the connection should be closed. The connection will be closed
         * iff close is <code>true</code>.
         *
         * @param	data	the data to send to the client.
         * @param  close   <code>boolean</code> indicating whether or not the
         *                  connection should be closed.
         */
        public void reply(Object data, Boolean close)// throws
        {
            try
            {
                if (currentServerState != SERVER_STATE_RECEIVED)
                {
                    throw new InvalidOperationException("Cannot call reply(Object, boolean) on a ConnectionServer that has not received an unacknowledge request.");
                }

                //set open to true before replying
                msg.data = data;
                msg.open = !close;
                toClient.write(msg);
                if (close)
                {
                    currentServerState = SERVER_STATE_CLOSED;
                    toClient           = null;
                    setAltingChannel(openIn);
                    currentInputChannel = openIn;
                }
                else
                {
                    currentServerState = SERVER_STATE_OPEN;
                }
            }
            catch (InvalidOperationException)
            {
                throw;
            }
        }
Пример #5
0
 public QueuingCanteen(ChannelInput service, ChannelOutput deliver, ChannelInput supply, ChannelOutput toConsole)
 {
     this.service   = service;
     this.deliver   = deliver;
     this.supply    = supply;
     this.toConsole = toConsole;
 }
Пример #6
0
 /**
  * Construct a new <TT>Printer</TT>.
  *
  * @param in he channel from which to read
  * @param printStream the stream to which to write
  * @param prefix the string to write in front of each object
  * @param postfix the string to write after each object
  */
 public Printer(ChannelInput In, StreamWriter printStream, String prefix, String postfix)
 {
     this.In          = In;
     this.printStream = printStream;
     this.prefix      = prefix;
     this.postfix     = postfix;
 }
Пример #7
0
 public GConsole(ChannelInput toConsole, ChannelOutput fromConsole, ChannelInput clearInputArea, string frameLabel)
 {
     this.toConsole      = toConsole;
     this.fromConsole    = fromConsole;
     this.clearInputArea = clearInputArea;
     this.frameLabel     = frameLabel;
 }
 public ResetUser(ChannelOutput resetValue, ChannelOutput toConsole, AltingChannelInput fromConverter,
                  ChannelOutput toClearOutput)
 {
     this.resetValue    = resetValue;
     this.toConsole     = toConsole;
     this.fromConverter = fromConverter;
     this.toClearOutput = toClearOutput;
 }
Пример #9
0
 public ResetPrefix(int prefixValue, ChannelOutput outChannel, AltingChannelInput inChannel,
                    ChannelInput resetChannel)
 {
     this.prefixValue  = prefixValue;
     this.outChannel   = outChannel;
     this.inChannel    = inChannel;
     this.resetChannel = resetChannel;
 }
 /**
  * Constructs a new server instance. This must be called by a subclass which is responsible for
  * creating the channels.
  */
 protected internal AltingConnectionServerImpl(AltingChannelInput openIn,
                                               AltingChannelInput furtherRequestIn) : base(openIn)
 {
     this.openIn              = openIn;
     this.furtherRequestIn    = furtherRequestIn;
     this.currentInputChannel = openIn;
     currentServerState       = SERVER_STATE_CLOSED;
 }
Пример #11
0
 public Vestibule(Bucket[] groups, ChannelInput needToConsult, ChannelOutput joinGroup,
                  ChannelInput openForBusiness, ChannelInput consultationOver)
 {
     this.groups           = groups;
     this.needToConsult    = needToConsult;
     this.joinGroup        = joinGroup;
     this.openForBusiness  = openForBusiness;
     this.consultationOver = consultationOver;
 }
        public ActionResult Add(string a)
        {
            //3. Create a channel
            //3.1 Create Channel Input
            var input = new ChannelInput
            {
                StreamingProtocol = StreamingProtocol.RTMP,
                AccessControl     = new ChannelAccessControl
                {
                    IPAllowList = new List <IPRange>
                    {
                        new IPRange {
                            Name               = "MyInput",
                            Address            = IPAddress.Parse("0.0.0.0"),
                            SubnetPrefixLength = 0
                        }
                    }
                }
            };

            //3.2 Create Channel Preview

            var preview = new ChannelPreview
            {
                AccessControl = new ChannelAccessControl
                {
                    IPAllowList = new List <IPRange>()
                    {
                        new IPRange {
                            Name               = "MyPreview",
                            Address            = IPAddress.Parse("0.0.0.0"),
                            SubnetPrefixLength = 0
                        }
                    }
                }
            };

            //3.3 Create Channel Output
            var output = new ChannelOutput {
                Hls = new ChannelOutputHls {
                    FragmentsPerSegment = 1
                }
            };

            var channel = _context.Channels.Create(new ChannelCreationOptions
            {
                Name    = "Channel-Returngis-1",
                Input   = input,
                Preview = preview,
                Output  = output
            });

            channel.Start();

            return(View());
        }
Пример #13
0
 public Controller(long testInterval, long computeInterval, int addition, ChannelInput factor,
                   ChannelOutput suspend, ChannelOutput injector)
 {
     this.testInterval    = testInterval;
     this.computeInterval = computeInterval;
     this.addition        = addition;
     this.factor          = factor;
     this.suspend         = suspend;
     this.injector        = injector;
 }
 public Reindeer(int number, AltingBarrier stable, ChannelOutput harness, ChannelInput harnessed,
                 ChannelInput returned, ChannelInput unharness, int holidayTime)
 {
     this.number      = number;
     this.stable      = stable;
     this.harness     = harness;
     this.harnessed   = harnessed;
     this.returned    = returned;
     this.unharness   = unharness;
     this.holidayTime = holidayTime;
 }
Пример #15
0
 public Scale(ChannelInput inChannel, ChannelOutput outChannel, ChannelOutput factor, ChannelInput suspend,
              ChannelInput injector, int multiplier, int scaling)
 {
     this.outChannel = outChannel;
     this.factor     = factor;
     this.inChannel  = inChannel;
     this.suspend    = suspend;
     this.injector   = injector;
     this.multiplier = multiplier;
     this.scaling    = scaling;
 }
 protected internal SharedConnectionServerImpl(AltingChannelInput openIn,
                                               AltingChannelInput requestIn,
                                               ChannelInput synchIn,
                                               SharedChannelOutput synchOut,
                                               ConnectionWithSharedAltingServer parent)
 {
     connectionServerToUse = new AltingConnectionServerImpl(openIn, requestIn);
     this.synchOut         = synchOut;
     this.synchIn          = synchIn;
     this.parent           = parent;
 }
 protected internal SharedAltingConnectionClient(AltingChannelInput fromServer,
                                                 ChannelInput synchIn,
                                                 ChannelOutput openToServer,
                                                 ChannelOutput reqToServer,
                                                 SharedChannelOutput synchOut,
                                                 ChannelOutput backToClient,
                                                 ConnectionWithSharedAltingClient
                                                 parent) : base(fromServer, openToServer, reqToServer, backToClient)
 {
     this.synchIn  = synchIn;
     this.synchOut = synchOut;
     this.parent   = parent;
 }
Пример #18
0
 public Elf(int number, Bucket[] groups, ChannelOutput needToConsult, ChannelInput joinGroup,
            ChannelOutput consult, ChannelInput consulting, ChannelOutput negotiating, ChannelInput consulted,
            int workingTime)
 {
     this.number        = number;
     this.groups        = groups;
     this.needToConsult = needToConsult;
     this.joinGroup     = joinGroup;
     this.consult       = consult;
     this.consulting    = consulting;
     this.negotiating   = negotiating;
     this.consulted     = consulted;
     this.workingTime   = workingTime;
 }
        public void SettingsTestChannelSubProperties()
        {
            IChannel target = new ChannelData();

            var input = new ChannelInput
            {
                 AccessControl = new ChannelAccessControl
                 {
                     IPAllowList = new List<IPRange> {new IPRange {Address = IPAddress.Parse("192.168.0.1/24"), SubnetPrefixLength = 24} }
                 }
            };

            target.Input = input;

            Assert.IsNotNull(target.Input.AccessControl.IPAllowList.FirstOrDefault());
        }
Пример #20
0
 public Santa(ChannelOutput openForBusiness, ChannelOutput consultationOver, ChannelInput harness,
              ChannelOutput harnessed, ChannelOutput returned, ChannelOutputList unharnessList, AltingBarrier stable,
              ChannelInput consult, ChannelOutputList consulting, ChannelInput negotiating, ChannelOutputList consulted,
              int deliveryTime, int consultationTime)
 {
     this.openForBusiness  = openForBusiness;
     this.consultationOver = consultationOver;
     this.harness          = harness;
     this.harnessed        = harnessed;
     this.returned         = returned;
     this.unharnessList    = unharnessList;
     this.stable           = stable;
     this.consult          = consult;
     this.consulting       = consulting;
     this.negotiating      = negotiating;
     this.consulted        = consulted;
     this.deliveryTime     = deliveryTime;
     this.consultationTime = consultationTime;
 }
        public void SettingsTestChannelSubProperties()
        {
            IChannel target = new ChannelData();

            var input = new ChannelInput
            {
                AccessControl = new ChannelAccessControl
                {
                    IPAllowList = new List <IPRange> {
                        new IPRange {
                            Address = IPAddress.Parse("192.168.0.1/24"), SubnetPrefixLength = 24
                        }
                    }
                }
            };

            target.Input = input;

            Assert.IsNotNull(target.Input.AccessControl.IPAllowList.FirstOrDefault());
        }
        /// <summary>
        /// Creates an instance of ChannelInputData class from an instance of ChannelInput.
        /// </summary>
        /// <param name="input">Channel Input to copy into newly created instance.</param>
        public ChannelInputData(ChannelInput input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            KeyFrameInterval = input.KeyFrameInterval;
            StreamingProtocol = input.StreamingProtocol.ToString();
            AccessControl = input.AccessControl == null
                ? null
                : new ChannelAccessControlData(input.AccessControl);

            if (input.Endpoints != null)
            {
                Endpoints = input.Endpoints
                    .Select(e => e == null ? null : new ChannelEndpointData(e))
                    .ToList();
            }
        }
        /// <summary>
        /// Creates an instance of ChannelCreationOptions class.
        /// </summary>
        /// <param name="name">Name of the channel to be created</param>
        /// <param name="inputStreamingProtocol">the Streaming Protocol of the channel input</param>
        /// <param name="inputIPAllowList">the IP allow list for the channel input access control</param>
        public ChannelCreationOptions(
            string name, 
            StreamingProtocol inputStreamingProtocol,
            IEnumerable<IPRange> inputIPAllowList)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }
            if (inputIPAllowList == null)
            {
                throw new ArgumentNullException("inputIPAllowList");
            }

            Name = name;
            Input = new ChannelInput
            {
                StreamingProtocol = inputStreamingProtocol,
                AccessControl = new ChannelAccessControl
                {
                    IPAllowList = (inputIPAllowList as IList<IPRange>) ?? inputIPAllowList.ToList()
                }
            };
        }
Пример #24
0
 public LoopsProcess(ChannelInput c, ChannelOutput reset)
 {
     this.c     = c;
     this.reset = reset;
 }
Пример #25
0
 public Philosopher(int id, ChannelOutput service, ChannelInput deliver)
 {
     this.id      = id;
     this.service = service;
     this.deliver = deliver;
 }
Пример #26
0
 public Delta2(ChannelInput In, ChannelOutput Out1, ChannelOutput Out2)
 {
     this.In   = In;
     this.out1 = Out1;
     this.out2 = Out2;
 }
 /**
  * Constructs a new <code>FilteredChannelInputWrapper</code> around the existing channel end.
  *
  * @param in channel end to create the wrapper around.
  */
 internal FilteredChannelInputWrapper(ChannelInput In) : base(In)
 {
 }
Пример #28
0
 /**
  * Construct a new Plus process with the input Channels in1 and in2 and the
  * output Channel out. The ordering of the Channels in1 and in2 make
  * no difference to the functionality of this process.
  *
  * @param in1 The first input Channel
  * @param in2 The second input Channel
  * @param out The output Channel
  */
 public Plus(ChannelInput In1, ChannelInput In2, ChannelOutput Out)
 {
     this.In1 = In1;
     this.In2 = In2;
     this.Out = Out;
 }
 /**
  * Creates a new filtered channel input end around an existing channel end.
  *
  * @param in the existing channel end.
  * @return the created channel end.
  */
 public FilteredChannelInput createFiltered(ChannelInput In)
 {
     return(new FilteredChannelInputWrapper(In));
 }
Пример #30
0
 public Regulator2Timers(ChannelInput In, ChannelOutput Out)
 {
     this.In  = In;
     this.Out = Out;
 }
Пример #31
0
 /**
  * Construct a new <TT>ProcessRead</TT>.
  *
  * @param in the channel from which to read
  */
 public ProcessRead(ChannelInput inChannel)
 {
     this.inChannel = inChannel;
 }
Пример #32
0
 /**
  * Constructs a new wrapper around the given channel end.
  *
  * @param in the existing channel end.
  */
 public ChannelInputWrapper(ChannelInput In)
 {
     this.In = In;
 }
 public ResetNumbers(AltingChannelInput resetChannel, int initialValue, ChannelOutput outChannel)
 {
     this.resetChannel = resetChannel;
     this.initialValue = initialValue;
     this.outChannel   = outChannel;
 }