예제 #1
0
 public TCPClient(Control control, ConnectDelegate connectDelegate, DisconnectDelegate disconnectDelegate, ServerMessageDelegate messageDelegate)
 {
     this.control            = control;
     this.connectDelegate    = connectDelegate;
     this.disconnectDelegate = disconnectDelegate;
     AddMessageDelegate(messageDelegate);
 }
예제 #2
0
 private void socket_socketDisconnected(string socketId)
 {
     try {
         DisconnectDelegate disconnectEvent = new DisconnectDelegate(lStatus.CloseStatusConnection);
         if (Connected() == true)
         {
             _invoke.Invoke(disconnectEvent, statusId, false);
         }
     } catch (Exception ex) {
         //Throw ex
     }
 }
예제 #3
0
 public void Disconnect()
 {
     if (InvokeRequired)
     {
         var d = new DisconnectDelegate(Disconnect);
         Invoke(d, new object[] { });
     }
     else
     {
         TN3270.Close();
         Rtf = "";
     }
 }
예제 #4
0
        /// <summary>
        /// Starts disconnecting connection.
        /// </summary>
        /// <param name="callback">Callback to call when the asynchronous operation is complete.</param>
        /// <param name="state">User data.</param>
        /// <returns>An IAsyncResult that references the asynchronous disconnect.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        /// <exception cref="InvalidOperationException">Is raised when TCP client is not connected.</exception>
        public IAsyncResult BeginDisconnect(AsyncCallback callback, object state)
        {
            if (m_IsDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (!IsConnected)
            {
                throw new InvalidOperationException("TCP client is not connected.");
            }

            DisconnectDelegate asyncMethod = Disconnect;
            AsyncResultState   asyncState  = new AsyncResultState(this, asyncMethod, callback, state);

            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(asyncState.CompletedCallback, null));

            return(asyncState);
        }
예제 #5
0
 public void SetDisconnect()
 {
     if (echoListBox.InvokeRequired)
     {
         var d = new DisconnectDelegate(SetDisconnect);
         Invoke(d);
     }
     else
     {
         echoListBox.Items.Clear();
         if (btnConnect.Enabled == false)
         {
             btnConnect.Enabled    = true;
             btnDisconnect.Enabled = false;
         }
         labelStatus.Text = "서버 접속이 끊어짐";
     }
     SendPacketQueue.Clear();
 }
예제 #6
0
 internal ClientState()
 {
     this.Server = String.Empty;
     this.Port = String.Empty;
     this.Nickname = String.Empty;
     this.Password = String.Empty;
     this.ControlChat = null;
     this.Clipboard = null;
     this.Video = null;
     this.ClipboardPort = null;
     this.VideoPort = null;
     this.Transmitting = false;
     this.WorkEnd = false;
     this.wChatClipboard = null;
     this.wVideo = null;
     this.Clipper = null;
     this.Reader = null;
     this.Watcher = null;
     this.dDisconnect = null;
     this.dUpdateHistory = null;
     this.dSendClipboard = null;
     this.dUpdateVideo = null;
 }
예제 #7
0
 public static extern bool EnableDisconnectNotification(DisconnectDelegate Callback);
예제 #8
0
        /// <summary>
        /// Starts disconnecting connection.
        /// </summary>
        /// <param name="callback">Callback to call when the asynchronous operation is complete.</param>
        /// <param name="state">User data.</param>
        /// <returns>An IAsyncResult that references the asynchronous disconnect.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        /// <exception cref="InvalidOperationException">Is raised when TCP client is not connected.</exception>
        public IAsyncResult BeginDisconnect(AsyncCallback callback,object state)
        {
            if(m_IsDisposed){
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if(!m_IsConnected){
                throw new InvalidOperationException("TCP client is not connected.");
            }

            DisconnectDelegate asyncMethod = new DisconnectDelegate(this.Disconnect);
            AsyncResultState asyncState = new AsyncResultState(this,asyncMethod,callback,state);
            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(new AsyncCallback(asyncState.CompletedCallback),null));

            return asyncState;
        }
예제 #9
0
        static public bool StartFilter(string registerKey, int threadCount, FilterDelegate filterCallback, DisconnectDelegate disconnectCallback)
        {
            if (!isFilterStarted)
            {
                if (!SetRegistrationKey(registerKey))
                {
                    return(false);
                }

                gchFilter = GCHandle.Alloc(filterCallback);
                IntPtr filterCallbackPtr = Marshal.GetFunctionPointerForDelegate(filterCallback);

                gchDisconnect = GCHandle.Alloc(disconnectCallback);
                IntPtr disconnectCallbackPtr = Marshal.GetFunctionPointerForDelegate(disconnectCallback);

                isFilterStarted = RegisterMessageCallback(threadCount, filterCallbackPtr, disconnectCallbackPtr);
            }

            return(isFilterStarted);
        }
예제 #10
0
 public static extern bool EnableDisconnectNotification(DisconnectDelegate Callback);
예제 #11
0
        static public bool StartFilter(int threadCount, string registerKey, FilterDelegate filterCallback, DisconnectDelegate disconnectCallback, ref string lastError)
        {
            bool ret = true;

            try
            {
                if (IsDriverChanged() || !FilterAPI.IsDriverServiceRunning())
                {
                    FilterAPI.UnInstallDriver();

                    //wait for 3 seconds for the uninstallation completed.
                    System.Threading.Thread.Sleep(3000);

                    ret = FilterAPI.InstallDriver();
                    if (!ret)
                    {
                        lastError = "Installed driver failed with error:" + FilterAPI.GetLastErrorMessage();
                        return(false);
                    }
                    else
                    {
                        isFilterStarted = false;
                        EventManager.WriteMessage(59, "InstallDriver", EventLevel.Information, "Install filter driver succeeded.");
                    }
                }


                if (!isFilterStarted)
                {
                    if (!SetRegistrationKey(registerKey))
                    {
                        lastError = "Set registration key failed with error:" + GetLastErrorMessage();
                        return(false);
                    }

                    gchFilter = GCHandle.Alloc(filterCallback);
                    IntPtr filterCallbackPtr = Marshal.GetFunctionPointerForDelegate(filterCallback);

                    gchDisconnect = GCHandle.Alloc(disconnectCallback);
                    IntPtr disconnectCallbackPtr = Marshal.GetFunctionPointerForDelegate(disconnectCallback);

                    isFilterStarted = RegisterMessageCallback(threadCount, filterCallbackPtr, disconnectCallbackPtr);
                    if (!isFilterStarted)
                    {
                        lastError = "RegisterMessageCallback failed with error:" + GetLastErrorMessage();
                        return(false);
                    }

                    ret = true;
                }
            }
            catch (Exception ex)
            {
                ret       = false;
                lastError = "Start filter failed with error " + ex.Message;
            }
            finally
            {
                if (!ret)
                {
                    lastError = lastError + " Make sure you run this application as administrator.";
                }
            }

            return(ret);
        }
예제 #12
0
 private void socket_socketDisconnected(string socketId)
 {
     try {
         DisconnectDelegate disconnectEvent = new DisconnectDelegate(lStatus.CloseStatusConnection);
         if (Connected() == true)
             _invoke.Invoke(disconnectEvent, statusId, false);
     } catch (Exception ex) {
         //Throw ex
     }
 }