Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string hostName = Dns.GetHostName();
            IPAddress[] ipAddressList = Dns.GetHostEntry(hostName).AddressList;
            string ipAddress = string.Empty;
            foreach (var item in ipAddressList) {
                if (item.AddressFamily == AddressFamily.InterNetwork) {
                    ipAddress += item.ToString() + ";";
                }
            }
            ipAddress = ipAddress.TrimEnd(";".ToCharArray());

            string userName = this.textBox1.Text.Trim();
            if (string.IsNullOrEmpty(userName)) {
                return;
            }

            SessionClientInfo clientInfo = new SessionClientInfo() { IPAddress = ipAddress, HostName = hostName, UserName = userName };
            SessionUtility.StartSession(clientInfo);
            //this.groupBox2.Enabled = false;
        }
 public Guid StartSession(SessionClientInfo clientInfo, out TimeSpan timeout)
 {
     timeout = SessionManager.TimeOut;
     return SessionManager.StartSession(clientInfo);
 }
 public static void StartSession(SessionClientInfo clientInfo)
 {
     TimeSpan timeout;
     SessionID = Channel.StartSession(clientInfo, out timeout);
     Timeout = timeout;
 }
        public static Guid StartSession(SessionClientInfo clientInfo)
        {
            var sessionID = Guid.NewGuid();
            ISessionCallback callBack = OperationContext.Current.GetCallbackChannel<ISessionCallback>();
            SessionInfo sessionInfo = new SessionInfo();
            sessionInfo.ClientInfo = clientInfo;
            sessionInfo.LastActivityTime = DateTime.Now;
            sessionInfo.SessionID = sessionID;
            sessionInfo.StartTime = DateTime.Now;

            lock (_syncHelper) {
                CurrentCallbackList.Add(sessionID, callBack);
                CurrentSessionList.Add(sessionID, sessionInfo);
            }

            return sessionID;
        }