예제 #1
0
        void Close()
        {
            if (IsClose)
            {
                return;
            }
            Debug.LogError("CloseRemoteClient");
            if (mSocket != null)
            {
                try
                {
                    if (mSocket != null && mSocket.Connected)
                    {
                        mSocket.Shutdown(SocketShutdown.Both);
                    }
                    mSocket.Close();
                } catch (Exception exception)
                {
                    Debug.LogError(exception.ToString());
                }
            }
            mSocket = null;
            IsClose = true;

            if (evtHandler != null)
            {
                SendEvt(RemoteClientEvent.Close);
            }
            evtHandler = null;
            msgHandler = null;
        }
예제 #2
0
        public IEnumerator SendWaitResponse(byte[] data, uint fid, KBEngine.MessageHandler handler)
        {
            var ret = false;

            flowHandler.Add(fid, (packet) => {
                handler(packet);
                ret = true;
            });
            Send(data);
            while (!ret)
            {
                yield return(null);
            }
        }