Exemplo n.º 1
0
        public static void StartSession(SessionClientInfo clientInfo)
        {
            TimeSpan timeout;

            SessionID = Channel.StartSession(clientInfo, out timeout);
            Timeout   = timeout;
        }
Exemplo n.º 2
0
        private void buttonStartSession_Click(object sender, EventArgs e)
        {
            string hostName = Dns.GetHostName();

            IPAddress[] ipAddressList = Dns.GetHostEntry(hostName).AddressList;
            string      ipAddress     = string.Empty;

            foreach (IPAddress address in ipAddressList)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    ipAddress += address.ToString() + ";";
                }
            }
            ipAddress = ipAddress.TrimEnd(";".ToCharArray());

            string userName = this.textBoxUserName.Text.Trim();

            if (string.IsNullOrEmpty(userName))
            {
                return;
            }

            SessionClientInfo clientInfo = new SessionClientInfo()
            {
                IPAddress = ipAddress, HostName = hostName, UserName = userName
            };

            SessionUtility.StartSession(clientInfo);
            this.groupBox2.Enabled = false;
        }
Exemplo n.º 3
0
        private void Init()
        {
            CallbackService = new CalculatorCallbackService();
            //CallbackService.Quit += new EventHandler(cb_Quit);
            CallbackService.Processed += cb_Process;

            InstanceContext callback = new InstanceContext(CallbackService);

            ChannelFactory = new DuplexChannelFactory <ICalculator>(callback, "calculatorservice");

            Calculator = ChannelFactory.CreateChannel();
            SessionUtility.Callback = CallbackService as ISessionCallback;
            SessionUtility.Channel  = Calculator as ISessionManagement;
            //calculator.Add(1, 2);
            //请求服务器端数据
            SessionClientInfo clientInfo = new SessionClientInfo()
            {
                IPAddress = "127.0.0.1", HostName = "1", UserName = "******"
            };

            TimeSpan timeout;

            Calculator.StartSession(clientInfo, out timeout);

            //var client = new CalculatorClient(callback);
            //var d1 = client.GetProcessData("aa");
            var data = Calculator.GetProcessData("client1");

            if (data != null && data.Count > 0)
            {
                //Thread t1 = new Thread(new ParameterizedThreadStart(DoSomethingWithParameterV2));
                //t1.SetApartmentState(ApartmentState.STA);
                //t1.Start(data);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Start a new session.
        /// </summary>
        /// <param name="clientInfo">The client information regarding the current session.</param>
        /// <returns>The session ID in the form of Guid.</returns>
        public static Guid StartSession(SessionClientInfo clientInfo)
        {
            Guid             sessionID  = Guid.NewGuid();
            ISessionCallback callback   = OperationContext.Current.GetCallbackChannel <ISessionCallback>();
            SessionInfo      sesionInfo = new SessionInfo()
            {
                SessionID = sessionID, StartTime = DateTime.Now, LastActivityTime = DateTime.Now, ClientInfo = clientInfo
            };

            lock (_syncHelper)
            {
                CurrentSessionList.Add(sessionID, sesionInfo);
                CurrentCallbackList.Add(sessionID, callback);
            }
            return(sessionID);
        }
Exemplo n.º 5
0
        private void Init()
        {
            CallbackService = new CalculatorCallbackService();
            //CallbackService.Quit += new EventHandler(cb_Quit);
            CallbackService.Processed += cb_Process;

            InstanceContext callback = new InstanceContext(CallbackService);
            ChannelFactory = new DuplexChannelFactory<ICalculator>(callback, "calculatorservice");

            Calculator = ChannelFactory.CreateChannel();
            SessionUtility.Callback = CallbackService as ISessionCallback;
            SessionUtility.Channel = Calculator as ISessionManagement;
            //calculator.Add(1, 2);
            //请求服务器端数据
            SessionClientInfo clientInfo = new SessionClientInfo() { IPAddress = "127.0.0.1", HostName = "1", UserName = "******" };

            TimeSpan timeout;
            Calculator.StartSession(clientInfo, out timeout);

            //var client = new CalculatorClient(callback);
            //var d1 = client.GetProcessData("aa");
            var data = Calculator.GetProcessData("client1");
            if (data != null && data.Count > 0)
            {
                //Thread t1 = new Thread(new ParameterizedThreadStart(DoSomethingWithParameterV2));
                //t1.SetApartmentState(ApartmentState.STA);
                //t1.Start(data);
            }
        }
 public static void StartSession(SessionClientInfo clientInfo)
 {
     TimeSpan timeout;
     SessionID = Channel.StartSession(clientInfo, out timeout);
     Timeout = timeout;
 }
Exemplo n.º 7
0
 public Guid StartSession(SessionClientInfo clientInfo, out TimeSpan timeout)
 {
     timeout = SessionManager.Timeout;
     return(SessionManager.StartSession(clientInfo));
 }
 /// <summary>
 /// Start a new session.
 /// </summary>
 /// <param name="clientInfo">The client information regarding the current session.</param>
 /// <returns>The session ID in the form of Guid.</returns>
 public static Guid StartSession(SessionClientInfo clientInfo)
 {
     Guid sessionID = Guid.NewGuid();
     ISessionCallback callback = OperationContext.Current.GetCallbackChannel<ISessionCallback>();
     SessionInfo sesionInfo = new SessionInfo() { SessionID = sessionID, StartTime = DateTime.Now, LastActivityTime = DateTime.Now, ClientInfo = clientInfo };
     lock (_syncHelper)
     {
         CurrentSessionList.Add(sessionID, sesionInfo);
         CurrentCallbackList.Add(sessionID, callback);
     }
     return sessionID;
 }