Ejemplo n.º 1
0
        /// <summary>
        /// Disconnects this connection.
        /// </summary>
        public void Disconnect()
        {
            if (_disconnectCalls > 0)
            {
                return;
            }

            _disconnectCalls++;
            _writeDone.WaitOne();

            try
            {
                ClientDisconnected(this, EventArgs.Empty);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch
#pragma warning restore CA1031 // Do not catch general exception types
            {
                // ignore
            }

            try
            {
                RemoteClient.Dispose();
                SecureStream?.Dispose();
                NetworkStream?.Dispose();
            }
            finally
            {
                NetworkStream            = null;
                SecureStream             = null;
                RemoteClient             = null;
                _continuousReadingThread = null;
            }
        }
Ejemplo n.º 2
0
 private void ClearUser()
 {
     if (IsActive)
     {
         if (MainWindow.CountPlayingUsers() <= 2)
         {
             MainWindow.NotEnoughPlayers();
         }
         if (IsPlaying)
         {
             Status    = STATUS.FOLD;
             IsPlaying = false;
         }
         for (int i = 0; i < MainWindow.usersHistory.Count; i++)
         {
             if (MainWindow.usersHistory[i].uID == UserData.uID)
             {
                 MainWindow.usersHistory[i] = new UserData(UserData);
             }
         }
         UserData = default;
         if (RemoteClient != null)
         {
             RemoteClient.Close();
             RemoteClient.Dispose();
             RemoteClient = null;
         }
         JoiningManagement.Refresh();
     }
 }
Ejemplo n.º 3
0
        //�I������
        public void Dispose()
        {
            //	        if (RunMode != RunMode.Service && RunMode != RunMode.Remote) {
            //	            //**********************************************
            //	            // ��U�t�@�C����폜���Č��ݗL���Ȃ�̂���������߂�
            //	            //**********************************************
            //	            var iniDb = new IniDb(ProgDir(),"Option");
            //	            iniDb.DeleteIni();

            //Ver5.8.6 Java fix
            if (RunMode == RunMode.Normal)
            {
                var iniTmp = new IniDb(ProgDir(), "$tmp");//�o�b�N�A�b�v��쐬����ini�t�@�C����폜����
                //��U�A�ʃt�@�C���Ɍ��ݗL���Ȃ�̂���������߂�
                ListOption.Save(iniTmp);
                //�㏑������
                File.Copy(iniTmp.Path, IniDb.Path, true);
                iniTmp.Delete();
            }
            else if (RunMode == RunMode.Remote)
            {
                IniDb.Delete(); //$Remote.ini�̍폜
            }


            //**********************************************
            // �j��
            //**********************************************
            ListServer.Dispose(); //�e�T�[�o�͒�~�����
            ListOption.Dispose();
            ListTool.Dispose();
            MailBox = null;
            //	        }
            if (RemoteClient != null)
            {
                RemoteClient.Dispose();
            }

            View.Dispose();
            if (TraceDlg != null)
            {
                TraceDlg.Dispose();
            }
            if (Menu != null)
            {
                Menu.Dispose();
            }
            if (WindowSize != null)
            {
                View.Save(WindowSize);
                WindowSize.Dispose(); //Dispose���Ȃ���Reg.Dispose(�ۑ�)����Ȃ�
            }
        }
Ejemplo n.º 4
0
        //終了処理
        public void Dispose()
        {
            //	        if (RunMode != RunMode.Service && RunMode != RunMode.Remote) {
            //	            //**********************************************
            //	            // 一旦ファイルを削除して現在有効なものだけを書き戻す
            //	            //**********************************************
            //	            var iniDb = new IniDb(ProgDir(),"Option");
            //	            iniDb.DeleteIni();

            //Ver5.8.6 Java fix
            if (RunMode == RunMode.Normal)
            {
                var iniTmp = new IniDb(ProgDir(), "$tmp");//バックアップを作成してiniファイルを削除する
                //一旦、別ファイルに現在有効なものだけを書き戻す
                ListOption.Save(iniTmp);
                //上書きする
                File.Copy(iniTmp.Path, IniDb.Path, true);
                iniTmp.Delete();
            }
            else if (RunMode == RunMode.Remote)
            {
                IniDb.Delete(); //$Remote.iniの削除
            }


            //**********************************************
            // 破棄
            //**********************************************
            ListServer.Dispose(); //各サーバは停止される
            ListOption.Dispose();
            ListTool.Dispose();
            MailBox = null;
            //	        }
            if (RemoteClient != null)
            {
                RemoteClient.Dispose();
            }

            View.Dispose();
            if (TraceDlg != null)
            {
                TraceDlg.Dispose();
            }
            if (Menu != null)
            {
                Menu.Dispose();
            }
            if (WindowSize != null)
            {
                View.Save(WindowSize);
                WindowSize.Dispose(); //DisposeしないとReg.Dispose(保存)されない
            }
        }
Ejemplo n.º 5
0
        public void ResolveProxyTypesLocal_ProxyObjectBase(ServerHost server, RemoteClient client, Type expectedType)
        {
            server.Start();
            client.ConnectAsync($"127.0.0.1:{server.ListenPort}").Wait();

            var proxy = client.GetRootObject <IMockRoot>();

            server.Dispose();
            client.Dispose();

            Assert.IsNotNull(proxy, "GetRootObject returned null!");
            Assert.IsTrue(proxy.GetType() == expectedType, $"Returned type not expected! {proxy} : {expectedType}");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Disconnects this connection.
        /// </summary>
        public void Disconnect()
        {
            if (_disconnectCalls > 0)
            {
                return;
            }

            _disconnectCalls++;
            _writeDone.WaitOne();

            try
            {
                ClientDisconnected(this, EventArgs.Empty);
            }
            catch
            {
                // ignore
            }

            try
            {
#if !NET452
                RemoteClient.Dispose();
                SecureStream?.Dispose();
                NetworkStream?.Dispose();
#else
                RemoteClient.Close();
                SecureStream?.Close();
                NetworkStream?.Close();
#endif
            }
            catch
            {
                // ignored
            }
            finally
            {
                NetworkStream            = null;
                SecureStream             = null;
                RemoteClient             = null;
                _continuousReadingThread = null;
            }
        }
Ejemplo n.º 7
0
 public static void CleanUp()
 {
     _client.Dispose();
     _server.Dispose();
 }
Ejemplo n.º 8
0
 protected override void OnDispose()
 {
     _client?.Dispose();
     _channel?.Dispose();
     Debug.WriteLine(this, "Disposed");
 }