session.cs

来自「ICE3.3.0--聊天程序服务器端demo」· CS 代码 · 共 67 行

CS
67
字号
// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Chat Demo is licensed to you under the terms
// described in the CHAT_DEMO_LICENSE file included in this// distribution.
//
// **********************************************************************

using System;
using System.Threading;

namespace ChatDemoGUI
{
    public class Session
    {
        //
        //
        // This class is responsible for keeping the session open and controlling its life time.
        //
        public Session(Chat.ChatSessionPrx session, long period)
        {
            this._session = session;
            this._sessionRefreshThread = new SessionRefreshThread(_session, period);
            this._thread = new Thread(new ThreadStart(this._sessionRefreshThread.run));
            this._thread.Start();
        }

        public Chat.ChatSessionPrx proxy()
        {
            return _session;
        }

        public void close()
        {
            _sessionRefreshThread.done();
            for(;;)
            {
                try
                {
                    _thread.Join();
                    break;
                }
                catch (ThreadStateException)
                {
                }
                catch (ThreadInterruptedException)
                {
                }
            }

            try
            {
                _session.destroy();
            }
            catch(Ice.LocalException)
            {
            }
        }

        private Chat.ChatSessionPrx _session;
        private SessionRefreshThread _sessionRefreshThread;
        private Thread _thread;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?