Пример #1
0
 public override void GetResponseObject()
 {
     if (responseObject == null)
     {
         this.responseObject = reusableSeaaBuffer.Checkout();
     }
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="serverBufferSize"></param>
 public TcpNetworkSender(
     Socket socket,
     int serverBufferSize)
     : base(serverBufferSize)
 {
     this.socket             = socket;
     this.reusableSeaaBuffer = new SimpleObjectPool <SeaaBuffer>(() => new SeaaBuffer(SeaaBuffer_Completed, this.serverBufferSize));
     this.responseObject     = null;
 }
Пример #3
0
 private unsafe void Send(Socket socket, SeaaBuffer sendObject, int offset, int size)
 {
     // Reset send buffer
     sendObject.socketEventAsyncArgs.SetBuffer(offset, size);
     // Set user context to reusable object handle for disposal when send is done
     sendObject.socketEventAsyncArgs.UserToken = sendObject;
     if (!socket.SendAsync(sendObject.socketEventAsyncArgs))
     {
         SeaaBuffer_Completed(null, sendObject.socketEventAsyncArgs);
     }
 }
Пример #4
0
        public override bool SendResponse(int offset, int size)
        {
            var _r = responseObject;

            if (_r == null)
            {
                return(false);
            }
            responseObject = null;
            try
            {
                Send(socket, _r, offset, size);
            }
            catch
            {
                reusableSeaaBuffer.Return(_r);
                return(false);
            }
            return(true);
        }
Пример #5
0
 public override void ReturnResponseObject()
 {
     reusableSeaaBuffer.Return(responseObject);
     responseObject = null;
 }
Пример #6
0
 /// <summary>
 /// Return to pool
 /// </summary>
 /// <param name="obj"></param>
 public void Return(SeaaBuffer obj) => reusableSeaaBuffer.Return(obj);