示例#1
0
        /// <summary>
        /// 销毁服务对象
        /// </summary>
        /// <returns></returns>
        public bool Destroy()
        {
            try
            {
                Stop();

                if (pServer != IntPtr.Zero)
                {
                    SDK.Destroy_HP_TcpServer(pServer);
                    pServer = IntPtr.Zero;
                }
                if (pListener != IntPtr.Zero)
                {
                    SDK.Destroy_HP_TcpServerListener(pListener);
                    pListener = IntPtr.Zero;
                }

                _IsCreate = false;

                _OnSend          = null;
                _OnClose         = null;
                _OnAccept        = null;
                _OnReceive       = null;
                _OnShutdown      = null;
                _OnPrepareListen = null;
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Initialize Callback
        /// </summary>
        protected void InitializeCallback()
        {
            _OnSend          = new SDK.OnSend(SDK_OnSend);
            _OnClose         = new SDK.OnClose(SDK_OnClose);
            _OnAccept        = new SDK.OnAccept(SDK_OnAccept);
            _OnReceive       = new SDK.OnReceive(SDK_OnReceive);
            _OnShutdown      = new SDK.OnShutdown(SDK_OnShutdown);
            _OnPrepareListen = new SDK.OnPrepareListen(SDK_OnPrepareListen);

            SDK.HP_Set_FN_Server_OnSend(pListener, _OnSend);
            SDK.HP_Set_FN_Server_OnClose(pListener, _OnClose);
            SDK.HP_Set_FN_Server_OnAccept(pListener, _OnAccept);
            SDK.HP_Set_FN_Server_OnReceive(pListener, _OnReceive);
            SDK.HP_Set_FN_Server_OnShutdown(pListener, _OnShutdown);
            SDK.HP_Set_FN_Server_OnPrepareListen(pListener, _OnPrepareListen);
        }