Exemple #1
0
        ///////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 设置回调函数
        /// </summary>
        /// <param name="prepareListen"></param>
        /// <param name="accept"></param>
        /// <param name="send"></param>
        /// <param name="recv"></param>
        /// <param name="close"></param>
        /// <param name="error"></param>
        /// <param name="shutdown"></param>
        public virtual void SetCallback(HPSocketSdk.OnPrepareListen prepareListen, HPSocketSdk.OnAccept accept, HPSocketSdk.OnSend send, HPSocketSdk.OnReceive recv, HPSocketSdk.OnClose close, HPSocketSdk.OnError error, HPSocketSdk.OnServerShutdown shutdown)
        {
            if (IsSetCallback == true)
            {
                throw new Exception("已经调用过SetCallback()方法,如果您确定没手动调用过该方法,并想要手动设置各回调函数,请在构造该类构造函数中传false值,并再次调用该方法。");
            }

            // 设置 Socket 监听器回调函数
            OnAcceptCallback         = new HPSocketSdk.OnAccept(accept);
            OnSendCallback           = new HPSocketSdk.OnSend(send);
            OnPrepareListenCallback  = new HPSocketSdk.OnPrepareListen(prepareListen);
            OnReceiveCallback        = new HPSocketSdk.OnReceive(recv);
            OnCloseCallback          = new HPSocketSdk.OnClose(close);
            OnErrorCallback          = new HPSocketSdk.OnError(error);
            OnServerShutdownCallback = new HPSocketSdk.OnServerShutdown(shutdown);

            // 设置 Socket 监听器回调函数
            HPSocketSdk.HP_Set_FN_Server_OnPrepareListen(pListener, OnPrepareListenCallback);
            HPSocketSdk.HP_Set_FN_Server_OnAccept(pListener, OnAcceptCallback);
            HPSocketSdk.HP_Set_FN_Server_OnSend(pListener, OnSendCallback);
            HPSocketSdk.HP_Set_FN_Server_OnReceive(pListener, OnReceiveCallback);
            HPSocketSdk.HP_Set_FN_Server_OnClose(pListener, OnCloseCallback);
            HPSocketSdk.HP_Set_FN_Server_OnError(pListener, OnErrorCallback);
            HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);

            IsSetCallback = true;
        }
Exemple #2
0
        /// <summary>
        /// 设置回调函数
        /// </summary>
        /// <param name="prepareListen"></param>
        /// <param name="accept"></param>
        /// <param name="send"></param>
        /// <param name="recv"></param>
        /// <param name="close"></param>
        /// <param name="error"></param>
        /// <param name="shutdown"></param>
        public virtual void SetCallback(HPSocketSdk.OnPrepareListen prepareListen,
                                        HPSocketSdk.OnAccept accept, HPSocketSdk.OnSend send,
                                        HPSocketSdk.OnPullReceive recv, HPSocketSdk.OnClose close,
                                        HPSocketSdk.OnError error, HPSocketSdk.OnServerShutdown shutdown)
        {
            // 设置 Socket 监听器回调函数
            OnPullReceiveCallback = new HPSocketSdk.OnPullReceive(recv);

            // 设置 Socket 监听器回调函数
            HPSocketSdk.HP_Set_FN_Server_OnPullReceive(pListener, OnPullReceiveCallback);

            base.SetCallback(prepareListen, accept, send, OnReceive, close, error, shutdown);
        }
Exemple #3
0
 public virtual void SetOnServerShutdownCallback(HPSocketSdk.OnServerShutdown shutdown)
 {
     OnServerShutdownCallback = new HPSocketSdk.OnServerShutdown(shutdown);
     HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);
 }
Exemple #4
0
        ///////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 设置回调函数
        /// </summary>
        /// <param name="prepareListen"></param>
        /// <param name="accept"></param>
        /// <param name="send"></param>
        /// <param name="recv"></param>
        /// <param name="close"></param>
        /// <param name="error"></param>
        /// <param name="shutdown"></param>
        public virtual void SetCallback(HPSocketSdk.OnPrepareListen prepareListen, HPSocketSdk.OnAccept accept, HPSocketSdk.OnSend send, HPSocketSdk.OnReceive recv, HPSocketSdk.OnClose close, HPSocketSdk.OnError error, HPSocketSdk.OnServerShutdown shutdown)
        {
            if (IsSetCallback == true)
            {
                throw new Exception("已经调用过SetCallback()方法,如果您确定没手动调用过该方法,并想要手动设置各回调函数,请在构造该类构造函数中传false值,并再次调用该方法。");
            }

            // 设置 Socket 监听器回调函数
            OnAcceptCallback = new HPSocketSdk.OnAccept(accept);
            OnSendCallback = new HPSocketSdk.OnSend(send);
            OnPrepareListenCallback = new HPSocketSdk.OnPrepareListen(prepareListen);
            OnReceiveCallback = new HPSocketSdk.OnReceive(recv);
            OnCloseCallback = new HPSocketSdk.OnClose(close);
            OnErrorCallback = new HPSocketSdk.OnError(error);
            OnServerShutdownCallback = new HPSocketSdk.OnServerShutdown(shutdown);

            // 设置 Socket 监听器回调函数
            HPSocketSdk.HP_Set_FN_Server_OnPrepareListen(pListener, OnPrepareListenCallback);
            HPSocketSdk.HP_Set_FN_Server_OnAccept(pListener, OnAcceptCallback);
            HPSocketSdk.HP_Set_FN_Server_OnSend(pListener, OnSendCallback);
            HPSocketSdk.HP_Set_FN_Server_OnReceive(pListener, OnReceiveCallback);
            HPSocketSdk.HP_Set_FN_Server_OnClose(pListener, OnCloseCallback);
            HPSocketSdk.HP_Set_FN_Server_OnError(pListener, OnErrorCallback);
            HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);

            IsSetCallback = true;
        }
Exemple #5
0
 public virtual void SetOnServerShutdownCallback(HPSocketSdk.OnServerShutdown shutdown)
 {
     OnServerShutdownCallback = new HPSocketSdk.OnServerShutdown(shutdown);
     HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);
 }