Exemple #1
0
        /// <exception cref="System.IO.IOException"></exception>
        public override void ProcessClient(Socket4Adapter sock)
        {
            Msg message = Msg.ReadMessage(MessageDispatcher(), Transaction(), sock);

            if (message.Equals(Msg.Ok))
            {
                try
                {
                    _currentByte = 0;
                    _length      = this._blob.GetLength();
                    _blob.GetStatusFrom(this);
                    _blob.SetStatus(Status.Processing);
                    FileInputStream inBlob = this._blob.GetClientInputStream();
                    Copy(inBlob, sock, true);
                    sock.Flush();
                    message = Msg.ReadMessage(MessageDispatcher(), Transaction(), sock);
                    if (message.Equals(Msg.Ok))
                    {
                        // make sure to load the filename to i_blob
                        // to allow client databasefile switching
                        Container().Deactivate(Transaction(), _blob, int.MaxValue);
                        Container().Activate(Transaction(), _blob, new FullActivationDepth());
                        this._blob.SetStatus(Status.Completed);
                    }
                    else
                    {
                        this._blob.SetStatus(Status.Error);
                    }
                }
                catch (Exception e)
                {
                    Sharpen.Runtime.PrintStackTrace(e);
                }
            }
        }
Exemple #2
0
 /// <exception cref="System.IO.IOException"></exception>
 public override void ProcessClient(Socket4Adapter sock)
 {
     var message = ReadMessage(MessageDispatcher(), Transaction(), sock);
     if (message.Equals(Ok))
     {
         try
         {
             _currentByte = 0;
             _length = _blob.GetLength();
             _blob.GetStatusFrom(this);
             _blob.SetStatus(Status.Processing);
             var inBlob = _blob.GetClientInputStream();
             Copy(inBlob, sock, true);
             sock.Flush();
             message = ReadMessage(MessageDispatcher(), Transaction(), sock);
             if (message.Equals(Ok))
             {
                 // make sure to load the filename to i_blob
                 // to allow client databasefile switching
                 Container().Deactivate(Transaction(), _blob, int.MaxValue);
                 Container().Activate(Transaction(), _blob, new FullActivationDepth());
                 _blob.SetStatus(Status.Completed);
             }
             else
             {
                 _blob.SetStatus(Status.Error);
             }
         }
         catch (Exception e)
         {
             Runtime.PrintStackTrace(e);
         }
     }
 }
Exemple #3
0
 public virtual void ProcessAtServer()
 {
     try
     {
         BlobImpl blobImpl = this.ServerGetBlobImpl();
         if (blobImpl != null)
         {
             blobImpl.SetTrans(Transaction());
             Sharpen.IO.File file   = blobImpl.ServerFile(null, false);
             int             length = (int)file.Length();
             Socket4Adapter  sock   = ServerMessageDispatcher().Socket();
             Msg.Length.GetWriterForInt(Transaction(), length).Write(sock);
             FileInputStream fin = new FileInputStream(file);
             Copy(fin, sock, false);
             sock.Flush();
             Msg.Ok.Write(sock);
         }
     }
     catch (Exception)
     {
         Write(Msg.Error);
     }
 }
Exemple #4
0
 public virtual bool Write(Socket4Adapter sock)
 {
     if (null == sock)
     {
         throw new ArgumentNullException();
     }
     lock (sock)
     {
         try
         {
             sock.Write(PayLoad()._buffer);
             sock.Flush();
             return(true);
         }
         catch (Exception)
         {
             // TODO: .NET convert SocketException to Db4oIOException
             // and let Db4oIOException bubble up.
             //e.printStackTrace();
             return(false);
         }
     }
 }
Exemple #5
0
 public virtual bool Write(Socket4Adapter sock)
 {
     if (null == sock)
     {
         throw new ArgumentNullException();
     }
     lock (sock)
     {
         try
         {
             sock.Write(PayLoad()._buffer);
             sock.Flush();
             return true;
         }
         catch (Exception)
         {
             // TODO: .NET convert SocketException to Db4oIOException
             // and let Db4oIOException bubble up.
             //e.printStackTrace();
             return false;
         }
     }
 }