Exemplo n.º 1
0
        /// <summary>
        /// Initializes the network provider.
        /// </summary>
        /// <param name="runtime">PSharpRuntime</param>
        /// <param name="applicationAssembly">ApplicationAssembly</param>
        public void Initialize(PSharpRuntime runtime, Assembly applicationAssembly)
        {
            this.Runtime             = runtime;
            this.ApplicationAssembly = applicationAssembly;

            //var channels = new Dictionary<string, IRemoteCommunication>();

            if (runtime.Configuration.ContainerId == 0)
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 1 + "/");

                WSHttpBinding   binding  = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory <IRemoteCommunication> .CreateChannel(binding, endpoint);
            }
            else
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 0 + "/");

                WSHttpBinding   binding  = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory <IRemoteCommunication> .CreateChannel(binding, endpoint);
            }
        }
        /// <summary>
        /// Initializes the network provider.
        /// </summary>
        /// <param name="runtime">PSharpRuntime</param>
        /// <param name="applicationAssembly">ApplicationAssembly</param>
        public void Initialize(PSharpRuntime runtime, Assembly applicationAssembly)
        {
            this.Runtime = runtime;
            this.ApplicationAssembly = applicationAssembly;

            //var channels = new Dictionary<string, IRemoteCommunication>();

            if (runtime.Configuration.ContainerId == 0)
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 1 + "/");

                WSHttpBinding binding = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory<IRemoteCommunication>.CreateChannel(binding, endpoint);
            }
            else
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 0 + "/");

                WSHttpBinding binding = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory<IRemoteCommunication>.CreateChannel(binding, endpoint);
            }
        }