예제 #1
0
        public override void run()
        {
            if (--duration == 40)
            {
                (actor as FirePillar).damage = 15;
                actor.anim = (actor as FirePillar).firePillar;
            }
            if (duration <= 0)
            {
                actor.removeMe = true;
            }

            //Determine which actors are hit
            foreach (Actor a in actor.getConeAround(36, new Vector2(0, 0), 360, null))
            {
                ILife liveAct = a as ILife;
                if (liveAct != null && a.actorcategory != Actor.ActorCategory.enemy)
                {
                    liveAct.life.life -= (actor as FirePillar).damage;
                }
            }

            // GLOWING
            int   beams      = 50;
            Color fifthwhite = new Color(0.5f, 0.1f, 0);
            float increment  = (float)Math.PI * 2 / beams;

            for (float x = 0; x < Math.PI * 2; x += increment)
            {
                actor.world.castRay(actor.position, new Vector2((float)Math.Cos(x), (float)Math.Sin(x)), fifthwhite);
            }
        }
예제 #2
0
 public virtual void Life_OnNoLife(ILife obj)
 {
     if (DestructableInPoolComponent)
     {
         DestructableInPoolComponent.mDestroy();
     }
 }
예제 #3
0
파일: ProxyHttp.cs 프로젝트: schifflee/bjd5
        //プロキシ処理
        override public bool Pipe(ILife iLife)
        {
            if (!SendServer(iLife))//サーバへの送信
            {
                return(false);
            }
            if (!RecvServer(iLife))//サーバからの受信
            {
                return(false);
            }
            if (!SendClient(iLife))//クライアントへの送信
            {
                return(false);
            }

            if (Proxy.Sock(CS.Server).SockState != SockState.Connect)
            {
                if (_indexClient == _ar.Count)
                {
                    return(false);
                }
            }
            //クライアントから切断された場合は、常に処理終了
            if (Proxy.Sock(CS.Client).SockState != SockState.Connect)
            {
                Proxy.Logger.Set(LogKind.Debug, null, 999, "□Break ClientSocket!=CONNECT");
                return(false);
            }

            return(true);
        }
예제 #4
0
        public override void collision(Actor a)
        {
            Vector2 dir = new Vector2(oldervelocity.X, oldervelocity.Y);

            if (dir != null)
            {
                dir.Normalize();
                dir *= this.velocity.Length() * 5;
                if (isSuper)
                {
                    dir *= Constants.ARROW_SUPERIMPULSE;
                }
                a.addImpulse(dir);
            }

            ILife l = a as ILife;

            if (l != null)
            {
                l.life.life -= Constants.ARROW_DAMAGE;
                if (isSuper)
                {
                    l.life.life -= Constants.ARROW_SUPERDAMAGE;
                }
            }

            if (!isSuper)
            {
                removeMe = true;
            }
        }
예제 #5
0
파일: ProxySsl.cs 프로젝트: schifflee/bjd5
        //データの受信
        //パラメータ cs CS.SERVER を設定した場合、buf[CS.SERVER]を処理対象とし、クライアント側に送信する
        bool RecvBuf(CS cs, ILife iLife)
        {
            SockTcp sock = Proxy.Sock(cs);

            if (sock == null)//サーバ側未接続
            {
                return(true);
            }

            var len = sock.Length();

            if (len == 0)
            {
                return(true);
            }
            var b = sock.Recv(len, Proxy.OptionTimeout, iLife);

            if (b == null)
            {
                return(false);
            }
            _oneObj.Body[cs].Add(b);
            _lastRecvServer = DateTime.Now.Ticks;
            return(true);
        }
예제 #6
0
파일: SockTcp.cs 프로젝트: schifflee/bjd5
        //1行受信
        //切断・タイムアウトでnullが返される
        public byte[] LineRecv(int sec, ILife iLife)
        {
            var tout = new util.Timeout(sec);

            while (iLife.IsLife())
            {
                //Ver5.1.6
                if (_sockQueue.Length == 0)
                {
                    Thread.Sleep(100);
                }
                byte[] buf = _sockQueue.DequeueLine();
                //noEncode = false;//テキストである事が分かっている
                Trace(TraceKind.Recv, buf, false);
                if (buf.Length != 0)
                {
                    //Ver5.8.6 Java fix
                    tout.Update(); //タイムアウトの更新
                    return(buf);
                }
                if (SockState != SockState.Connect)
                {
                    return(null);
                }
                if (tout.IsFinish())
                {
                    return(null); //タイムアウト
                }
                Thread.Sleep(1);
            }
            return(null);
        }
예제 #7
0
        //Content-Length形式の受信(RecvServer()から使用される)
        bool RecvServerContentLength(ILife iLife)
        {
            var len = _proxy.Sock(CS.Server).Length();

            if (len <= 0)
            {
                return(true);
            }

            var b = _proxy.Sock(CS.Server).Recv(len, _proxy.OptionTimeout, iLife);

            if (b == null)
            {
                return(false);
            }

            _oneObj.Body[CS.Server].Add(b);

            if (_isText)
            {
                //コンテンツ制限の確認
                if (_oneObj.Body[CS.Server].CanUse)  //Ver5.6.1
                {
                    if (IsHitLimitString(_oneObj.Body[CS.Server].Get()))
                    {
                        return(false);
                    }
                }
            }

            _lastRecvServer = DateTime.Now.Ticks;
            return(true);
        }
예제 #8
0
파일: ProxyHttp.cs 프로젝트: schifflee/bjd5
        //クライアント側への送信
        bool SendClient(ILife iLife)
        {
            for (int i = _indexClient; iLife.IsLife() && i < _ar.Count; i++)
            {
                if (!_ar[i].SendClient(iLife))
                {
                    return(false);
                }
                //クライアントへの送信が完了しているかどうかの確認
                if (_ar[i].SideState(CS.Client) != HttpSideState.ClientSideSendBody)
                {
                    break;
                }
                //送信が完了している場合は、次のデータオブジェクトの処理に移行する
                //proxy.Logger.Set(LogKind.Debug,null,999,string.Format("■indexClient {0}->{1}",indexClient,indexClient + 1));

                //キャッシュが可能な場合は、ここでキャッシュされる
                _ar[_indexClient].CacheWrite(_cache);
                //ここでオブジェクトは破棄される
                _ar[_indexClient].Dispose();

                _indexClient++;
            }
            return(true);
        }
예제 #9
0
    void DamagePlayer(GameObject player, float damage)
    {
        ILife shotPlayer = player.GetComponent <ILife> ();
        bool  killed;

        shotPlayer.Damage(damage, out killed);
    }
예제 #10
0
파일: ProxySsl.cs 프로젝트: schifflee/bjd5
 bool RecvClient(ILife iLife)
 {
     if (!RecvBuf(CS.Client, iLife))
     {
         return(false);
     }
     return(true);
 }
예제 #11
0
파일: ProxySsl.cs 프로젝트: schifflee/bjd5
 bool RecvServer(ILife iLife)
 {
     if (!RecvBuf(CS.Server, iLife))
     {
         return(false);
     }
     return(true);
 }
예제 #12
0
 public void Attack(ILife healt)
 {
     _health = healt;
     if (_attackingRoutine == null)
     {
         _attackingRoutine = StartCoroutine(StartAttacking());
     }
 }
예제 #13
0
    public EnemyDiceThrow GetEnemyDiceThrow(ILife _playerLife)
    {
        //basic distrubution
        int countToAttack  = Mathf.RoundToInt((_stats.MaxLifeForceUsage) * rationAttackToDefense);
        int countToDefense = _stats.MaxLifeForceUsage - countToAttack;


        return(new EnemyDiceThrow(countToAttack, countToDefense));
    }
예제 #14
0
        public SmtpClient(Ip ip, int port, int sec, ILife iLife)
        {
            _ip    = ip;
            _port  = port;
            _sec   = sec;
            _iLife = iLife;

            Status = SmtpClientStatus.Idle;
        }
예제 #15
0
 void UpdateLifeBar(ILife life)
 {
     if (LifeBar != null)
     {
         Vector3 localScale = LifeBar.localScale;
         localScale.x       = (float)life.Life / (float)life.StartingLife;
         LifeBar.localScale = localScale;
     }
 }
예제 #16
0
        public SmtpClient(Ip ip, int port, int sec, ILife iLife)
        {
            _ip = ip;
            _port = port;
            _sec = sec;
            _iLife = iLife;

            Status = SmtpClientStatus.Idle;
        }
예제 #17
0
        public PopClient(Kernel kernel, Ip ip, int port, int sec, ILife iLife)
        {
            _kernel = kernel;
            _ip     = ip;
            _port   = port;
            _sec    = sec;
            _iLife  = iLife;

            Status = PopClientStatus.Idle;
        }
        public override void collision(Actor a)
        {
            ILife live = a as ILife;

            if (live != null)
            {
                live.life.life -= damage;
            }
            removeMe = true;
        }
예제 #19
0
파일: PopClient.cs 프로젝트: jsakamoto/bjd5
        public PopClient(Kernel kernel,Ip ip,int port,int sec,ILife iLife)
        {
            _kernel = kernel;
            _ip = ip;
            _port = port;
            _sec = sec;
            _iLife = iLife;

            Status = PopClientStatus.Idle;
        }
예제 #20
0
파일: Response.cs 프로젝트: jsakamoto/bjd5
 //データ取得(内部データは、初期化される)
 public bool Recv(Logger logger, SockTcp sockTcp, int timeout, ILife iLife)
 {
     _logger = logger;
     //int limit = 3600;//文字数制限
     var str = sockTcp.AsciiRecv(timeout, iLife);
     if (str == null){
         return false;
     }
     return Interpretation(Inet.TrimCrlf(str));
 }
예제 #21
0
        public bool SendClient(ILife iLife)
        {
            if (_sideState[CS.Server] != HttpSideState.ServerSideRecvHeader && _sideState[CS.Server] != HttpSideState.ServerSideRecvBody)
            {
                return(true);
            }

            if (_sideState[CS.Client] == HttpSideState.ClientSideRecvRequest)
            {
                //サーバから受信したレスポンス及びヘッダをバッファに展開する
                var sendBuf = Bytes.Create(_response.ToString(), "\r\n", _oneObj.Header[CS.Server].GetBytes());
                if (!Send(_proxy.Sock(CS.Client), sendBuf))//送信
                {
                    return(false);
                }
                _sideState[CS.Client] = HttpSideState.ClientSideSendHeader;//ヘッダ送信完了
            }
            if (_sideState[CS.Client] == HttpSideState.ClientSideSendHeader)
            {
                //バッファに残っているデータの送信
                if (!SendBuf(CS.Server))
                {
                    return(false);
                }
            }

            //クライアントへの送信完了を確認する(ステータス変更)
            if (_oneHttpKind == OneHttpKind.ContentLength)   //Content-Lengthの場合
            //posがContentLengthまで達したら完了
            {
                if (_oneObj.Pos[CS.Server] >= _contentLength)
                {
                    _sideState[CS.Client] = HttpSideState.ClientSideSendBody;
                }
            }
            else if (_oneHttpKind == OneHttpKind.Chunk)     //chunkの場合
            //サーバ側の受信が完了し、バッファをすべて送信したら完了
            {
                if (_sideState[CS.Server] == HttpSideState.ServerSideRecvBody && _oneObj.Body[CS.Server].Length <= _oneObj.Pos[CS.Server])
                {
                    _sideState[CS.Client] = HttpSideState.ClientSideSendBody;
                }
            }
            //上記の条件で送信完了していない場合でも
            if (_sideState[CS.Client] != HttpSideState.ClientSideSendBody)
            {
                //サーバ側が切断され、受信未処理のデータが存在せず、バッファをすべて送信していたら完了
                if (_proxy.Sock(CS.Server).SockState == SockState.Error && _proxy.Sock(CS.Server).Length() == 0 && _oneObj.Body[CS.Server].Length <= _oneObj.Pos[CS.Server])
                {
                    _sideState[CS.Client] = HttpSideState.ClientSideSendBody;
                }
            }

            return(true);
        }
예제 #22
0
파일: FtpTunnel.cs 프로젝트: jsakamoto/bjd5
        //受信時の処理
        protected override byte[] Assumption(byte[] buf, ILife iLife)
        {
            var resultBuf = new byte[0];

            //一度に複数行分のデータが来る場合が有るので、行単位に分割して処理する
            var lines = Inet.GetLines(buf);
            foreach (var l in lines){
                resultBuf = Bytes.Create(resultBuf,AssumptionLine(l, iLife));
            }
            return resultBuf;
        }
예제 #23
0
 //キャッシュ情報取得処理
 //        public override long GetInfo(ref List<CacheInfo> infoList, int sleep, ref bool life) {
 public override long GetInfo(ref List<CacheInfo> infoList, int sleep, ILife iLife)
 {
     var size = 0L;
     foreach (var o in _ar) {
         if (!iLife.IsLife())
             return 0;
         infoList.Add(new CacheInfo(o.HostName, o.Port, o.Uri, o.LastModified, o.Expires, o.CreateDt, o.LastAccess, o.Length));
         size += o.Length;
     }
     return size;
 }
예제 #24
0
파일: Response.cs 프로젝트: schifflee/bjd5
        //データ取得(内部データは、初期化される)
        public bool Recv(Logger logger, SockTcp sockTcp, int timeout, ILife iLife)
        {
            _logger = logger;
            //int limit = 3600;//文字数制限
            var str = sockTcp.AsciiRecv(timeout, iLife);

            if (str == null)
            {
                return(false);
            }
            return(Interpretation(Inet.TrimCrlf(str)));
        }
        public override void collision(Actor a)
        {
            anim = new Animation(1, 1, 3f, false, 0, 0);
            anim.addEndAct((frame) => { removeMe = true; });

            ILife live = a as ILife;

            if (live != null)
            {
                live.life.life -= damage;
            }
        }
        public override void collision(Actor a)
        {
            ILife liveActor = a as ILife;

            if (liveActor == null)
            {
                return;
            }

            liveActor.life.life += 15;
            this.removeMe        = true;
        }
예제 #27
0
    void OnTriggerEnter2D(Collider2D col)
    {
        ILife life = col.GetComponent <ILife>();

        if (life != null)
        {
            init();
            life.TakeDamage(1);
            hitPool.getObject().GetComponent <HitEffect>().Hit(transform.position);
            AudioManager.PlayOneShot(AudioManager.Instance.bulletHits);
            pool.returnObject(gameObject);
        }
    }
예제 #28
0
        //受信時の処理
        protected override byte[] Assumption(byte[] buf, ILife iLife)
        {
            var resultBuf = new byte[0];

            //一度に複数行分のデータが来る場合が有るので、行単位に分割して処理する
            var lines = Inet.GetLines(buf);

            foreach (var l in lines)
            {
                resultBuf = Bytes.Create(resultBuf, AssumptionLine(l, iLife));
            }
            return(resultBuf);
        }
예제 #29
0
    void OntriggerEnter(Collider other)
    {
        ILife lifeable = other.GetComponent <ILife>();

        if (lifeable != null)
        {
            lifeable.ReceiveDamage(weaponConfig.Damage);
        }

        if (_onHit != null)
        {
            _onHit();
        }
    }
예제 #30
0
    private void OnCollisionEnter(Collision collision)
    {
        ILife life = collision.collider.gameObject.GetComponent <ILife>();

        if (life != null && life.GetDamage(1))
        {
            IScore score = collision.collider.gameObject.GetComponent <IScore>();
            if (score != null)
            {
                GameController.AddScore(score.GetScore());
            }
        }
        // GetComponent<Rigidbody>().velocity *= m_acceleration;
    }
예제 #31
0
    public void ShowActionCanvasFor(GameObject player, GameObject enemy, bool afterCombat)
    {
        if (GameManager.Instance.CurrentGameState == GameManager.GameState.PAUSED)
        {
            return;
        }


        if (enemy == null)
        {
            Debug.Log("[HUDmanager]: missing enemy object");
        }

        this._playerLifeForce = player.GetComponent <ILife>();
        _player = player.transform;
        if (this._playerLifeForce == null)
        {
            Debug.Log("[HUDmanager]: missing player component");
            return;
        }
        this._enemyLifeForce = enemy.GetComponentInParent <ILife>();
        _enemy = enemy.transform;
        if (this._enemyLifeForce == null)
        {
            Debug.Log("[HUDmanager]: missing enemy component");
        }
        this._enemyDiceAI = enemy.GetComponentInParent <EnemyDiceAI>();

        if (afterCombat)
        {
            ShowResult(true);
            if (enemy.gameObject.layer == 0)
            {
                return;
            }
        }
        else
        {
            ShowResult(false);
        }

        GameManager.Instance.UpdateState(GameManager.GameState.ACTION);
        _actionCanvas.enabled = true;
        _open = true;
        //ShowResult(false);
        SetAttack(0);
        SetDefense(0);
        UpdateActionPanel();
    }
예제 #32
0
        public void attack()
        {
            //Determine which actors are hit
            foreach (Actor a in actor.getConeAround(radius, direction, coneWidth, null))
            {
                ILife liveAct = a as ILife;
                if (a.collisionimmunitymask != Actor.ActorCategory.friendly && a.actorcategory != Actor.ActorCategory.nocategory)
                {
                    //Damage
                    if (liveAct != null)
                    {
                        liveAct.life.life -= damage;
                    }

                    //Impulse
                    Vector2 impulse = new Vector2();
                    impulse = (a.position - actor.position) * 2 / 3;
                    impulse.Normalize();

                    //Attack Impulse
                    impulse *= attackImpulse * a.mass / 10.0f;

                    //Attacker Speed Impulse
                    impulse += actor.velocity / 6;

                    //One side or the other Impulse
                    Vector2 offset = a.position - actor.position;
                    int     dir    = 0;
                    if (actor.velocity.X * offset.Y - offset.X * actor.velocity.Y > 0)
                    {
                        dir = 30;
                    }
                    else
                    {
                        dir = -30;
                    }
                    impulse += Vector2.Transform(impulse, Matrix.CreateRotationZ(MathHelper.ToRadians(dir)));

                    //End frame impulse
                    if (actor.anim.curFrame == actor.anim.frameEnd)
                    {
                        impulse *= 2f;
                    }

                    //Add Impulse!
                    a.addImpulse(impulse * 25);
                }
            }
        }
예제 #33
0
        static public void basicDamage(Actor a, Actor target, int damage, float impulse = 250)
        {
            ILife liveA = target as ILife;
            ILife liveB = a as ILife;

            if (liveA == null || liveA.life.dead || liveB.life.dead)
            {
                return;
            }

            if (target != null && !liveA.life.isGod && ((a.damageimmunitymask & target.actorcategory) == 0))
            {
                liveA.life.life -= damage;
            }
        }
예제 #34
0
        //キャッシュ情報取得処理
        //        public override long GetInfo(ref List<CacheInfo> infoList, int sleep, ref bool life) {
        public override long GetInfo(ref List <CacheInfo> infoList, int sleep, ILife iLife)
        {
            var size = 0L;

            foreach (var o in _ar)
            {
                if (!iLife.IsLife())
                {
                    return(0);
                }
                infoList.Add(new CacheInfo(o.HostName, o.Port, o.Uri, o.LastModified, o.Expires, o.CreateDt, o.LastAccess, o.Length));
                size += o.Length;
            }
            return(size);
        }
예제 #35
0
파일: ProxySsl.cs 프로젝트: schifflee/bjd5
 bool SendServer(ILife iLife)
 {
     //サーバ側との接続処理
     if (!Proxy.Connect(iLife, _oneObj.Request.HostName, _oneObj.Request.Port, _oneObj.Request.RequestStr, _oneObj.Request.Protocol))
     {
         Proxy.Logger.Set(LogKind.Debug, null, 999, "□Break http.Connect()==false");
         return(false);
     }
     //バッファに残っているデータの送信
     if (!SendBuf(CS.Client))
     {
         return(false);
     }
     return(true);
 }
예제 #36
0
 //指定したアドレス・ポートで待ち受けて、接続されたら、そのソケットを返す
 //失敗した時nullが返る
 //Ver5.9.2 Java fix
 //public static SockTcp CreateConnection(Kernel kernel,Ip ip, int port,ILife iLife){
 public static SockTcp CreateConnection(Kernel kernel,Ip ip, int port, Ssl ssl,ILife iLife)
 {
     //Ver5.9.2 Java fix
     //var sockServer = new SockServer(kernel,ProtocolKind.Tcp);
     var sockServer = new SockServer(kernel, ProtocolKind.Tcp,ssl);
     if (sockServer.SockState != SockState.Error) {
         const int listenMax = 1;
         if (sockServer.Bind(ip, port, listenMax)){
             while (iLife.IsLife()){
                 var child = (SockTcp) sockServer.Select(iLife);
                 if (child == null){
                     break;
                 }
                 sockServer.Close(); //これ大丈夫?
                 return child;
             }
         }
     }
     sockServer.Close();
     return null;
 }
예제 #37
0
        //受信(無効な場合 return null)
        public static OneRemoteData Recv(SockTcp sockTcp, ILife iLife)
        {
            if (sockTcp != null) {
                //Ver5.8.6
                var sec = 10;//最初はタイムアウト値を最小に設定する
                var b = sockTcp.Recv(1, sec, iLife);//REMOTE_DATA_KINDの受信
                if (b != null && b.Length == 1) {
                    var kind = (RemoteDataKind)b[0];

                    //これ以降は、データが到着しているはずなので、タイムアウト値を上げて待機する
                    //timeout = 3000;
                    //Ver5.8.6
                    sec = 10;
                    Thread.Sleep(1);
                    b = sockTcp.Recv(4, sec, iLife);//データサイズの受信

                    if (b != null && b.Length == 4) {
                        var len = BitConverter.ToInt32(b, 0);
                        if (len == 0) {
                            return new OneRemoteData(kind, "");//データ本体はサイズ0
                        }
                        //Ver5.8.6
                        b = new byte[0];
                        while (iLife.IsLife()) {
                            Thread.Sleep(1);
                            var buf = sockTcp.Recv(len, sec, iLife);//データ本体の受信
                            if (buf == null) {
                                return null;
                            }
                            b = Bytes.Create(b, buf);
                            if (b.Length == len){
                                return new OneRemoteData(kind, Encoding.GetEncoding(932).GetString(b));
                            }
                        }
                    }
                }
            }
            return null;
        }
예제 #38
0
파일: Tunnel.cs 프로젝트: jsakamoto/bjd5
        public void Pipe(SockTcp server, SockTcp client,ILife iLife)
        {
            Sock[CS.Client] = client;
            Sock[CS.Server] = server;

            //�A�C�h�������p�̃^�C�}������
            ResetIdle();

            var cs = CS.Server;
            while(iLife.IsLife()) {
                cs = Reverse(cs);//�T�[�o���ƃN���C�A���g�����݂ɏ�������
                Thread.Sleep(1);

                // �N���C�A���g�̐ؒf�̊m�F
                if(Sock[CS.Client].SockState != SockState.Connect) {

                    //Ver5.2.8
                    //�N���C�A���g���ؒf���ꂽ�ꍇ�ł�A�T�[�o�����ڑ����ő��M����ׂ��f�[�^���c���Ă���ꍇ�͏�����p������
                    if (Sock[CS.Server].SockState == SockState.Connect && Sock[CS.Client].Length() != 0) {

                    } else {
                        Logger.Set(LogKind.Detail, Sock[CS.Server], 9000043, "close client");
                        break;
                    }
                }

                //*******************************************************
                //��������f�[�^���������Ă��Ȃ��ꍇ�̏���
                //*******************************************************
                if(Sock[CS.Client].Length() == 0 && Sock[CS.Server].Length() == 0 && _byteBuf[CS.Client].Length == 0 && _byteBuf[CS.Server].Length == 0) {

                    // �T�[�o�̐ؒf�̊m�F
                    if(Sock[CS.Server].SockState != SockState.Connect) {

                        //���M����ׂ��f�[�^���Ȃ��A�T�[�o���ؒf���ꂽ�ꍇ�́A�����I��
                        Logger.Set(LogKind.Detail,Sock[CS.Server],9000044,"close server");
                        break;
                    }

                    Thread.Sleep(100);

                    //�A�C�h������ �^�C���A�E�g�̊m�F
                    if(IsTimeout()){
                        Logger.Set(LogKind.Normal,Sock[CS.Server],9000019,string.Format("option IDLETIME={0}min",IdleTime));
                        break;
                    }
                } else {
                    //�A�C�h�������p�̃^�C�}������
                    ResetIdle();
                }

                //*******************************************************
                // ��M����
                //*******************************************************
                if(_byteBuf[cs].Length == 0) { //�o�b�t�@����̎�������������
                    //�������ׂ��f�[�^���̎擾
                    var len = Sock[cs].Length();
                    if(len > 0) {
                        const int sec = 10; //��M�o�C�g�����킩���Ă���̂ŁA�����ł̃^�C���A�E�g�l�͂��܂�Ӗ�������
                        var b = Sock[cs].Recv(len,sec,iLife);
                        if(b != null){
                            //Assumption() ��M���̏���
                            _byteBuf[cs] = Bytes.Create(_byteBuf[cs],Assumption(b,iLife));
                        }
                    }
                }
                //*******************************************************
                // ���M����
                //*******************************************************
                if(_byteBuf[cs].Length != 0) { //�o�b�t�@�Ƀf�[�^�������Ă���ꍇ������������

                    var c = Sock[Reverse(cs)].SendUseEncode(_byteBuf[cs]);
                    if(c == _byteBuf[cs].Length) {
                        _byteBuf[cs] = new byte[0];
                    } else {
                        Logger.Set(LogKind.Error,server,9000020,string.Format("sock.Send() return {0}",c));
                        break;
                    }
                }
            }
        }
예제 #39
0
파일: ProxyFtp.cs 프로젝트: jsakamoto/bjd5
        //プロキシ処理
        public override bool Pipe(ILife iLife)
        {
            DataThread dataThread = null;
            var paramStr = "";

            //サーバ側との接続処理
            if(!Proxy.Connect(iLife,_oneObj.Request.HostName,_oneObj.Request.Port,_oneObj.Request.RequestStr,_oneObj.Request.Protocol)) {
                Proxy.Logger.Set(LogKind.Debug,null,999,"□Break proxy.Connect()==false");
                return false;
            }

            //wait 220 welcome
            if(!WaitLine("220",ref paramStr,iLife))
                return false;

            Proxy.Sock(CS.Server).AsciiSend(string.Format("USER {0}",_user));
            if(!WaitLine("331",ref paramStr,iLife))
                return false;

            Proxy.Sock(CS.Server).AsciiSend(string.Format("PASS {0}",_pass));
            if (!WaitLine("230", ref paramStr, iLife))
                return false;

            //Ver5.6.6
            if (_path == "/") {
                Proxy.Sock(CS.Server).AsciiSend("PWD");
                if (!WaitLine("257", ref paramStr, iLife))
                    return false;
                var tmp = paramStr.Split(' ');
                if (tmp.Length >= 1) {
                    _path = tmp[0].Trim(new[] { '"' });
                    if (_path[_path.Length - 1] != '/') {
                        _path = _path + "/";
                    }
                }
            }

            //リクエスト
            if(_path != "") {
                Proxy.Sock(CS.Server).AsciiSend(string.Format("CWD {0}",_path));
                if (!WaitLine("250", ref paramStr,iLife))
                    goto end;
            }

            Proxy.Sock(CS.Server).AsciiSend(_file == "" ? "TYPE A" : "TYPE I");
            if (!WaitLine("200", ref paramStr,iLife))
                goto end;

            //PORTコマンド送信
            var bindAddr = Proxy.Sock(CS.Server).LocalIp;
            // 利用可能なデータポートの選定
            while (iLife.IsLife()){
                DataPort++;
                if (DataPort >= 9999) {
                    DataPort = 2000;
                }
                if (SockServer.IsAvailable(_kernel,bindAddr, DataPort)){
                    break;
                }
            }
            int listenPort = DataPort;

            //データスレッドの生成
            dataThread = new DataThread(_kernel,bindAddr,listenPort);

            // サーバ側に送るPORTコマンドを生成する
            string str = string.Format("PORT {0},{1},{2},{3},{4},{5}", bindAddr.IpV4[0], bindAddr.IpV4[1], bindAddr.IpV4[2], bindAddr.IpV4[3], listenPort / 256, listenPort % 256);

            Proxy.Sock(CS.Server).AsciiSend(str);
            if (!WaitLine("200", ref paramStr, iLife))
                goto end;

            if(_file == "") {
                Proxy.Sock(CS.Server).AsciiSend("LIST");
                if (!WaitLine("150", ref paramStr, iLife))
                    goto end;
            } else {
                Proxy.Sock(CS.Server).AsciiSend("RETR " + _file);
                if (!WaitLine("150", ref paramStr, iLife))
                    goto end;

            }

            //Ver5.0.2
            while(iLife.IsLife()) {
                if(!dataThread.IsRecv)
                    break;
            }

            if (!WaitLine("226", ref paramStr,iLife))
                goto end;

            byte[] doc;
            if(_file == "") {
                //受信結果をデータスレッドから取得する
                List<string> lines = Inet.GetLines(dataThread.ToString());
                //FTPサーバから取得したLISTの情報をHTMLにコンバートする
                doc = ConvFtpList(lines,_path);
            } else {
                doc = dataThread.ToBytes();
            }

            //クライアントへリプライ及びヘッダを送信する
            var header = new Header();
            header.Replace("Server", Util.SwapStr("$v", _kernel.Ver.Version(),(string)_conf.Get("serverHeader")));

            header.Replace("MIME-Version","1.0");

            if(_file == "") {
                header.Replace("Date",Util.UtcTime2Str(DateTime.UtcNow));
                header.Replace("Content-Type","text/html");
            } else {
                header.Replace("Content-Type","none/none");
            }
            header.Replace("Content-Length",doc.Length.ToString());

            Proxy.Sock(CS.Client).AsciiSend("HTTP/1.0 200 OK");//リプライ送信
            Proxy.Sock(CS.Client).SendUseEncode(header.GetBytes());//ヘッダ送信
            Proxy.Sock(CS.Client).SendNoEncode(doc);//ボディ送信
            end:
            if(dataThread != null)
                dataThread.Dispose();

            return false;
        }
예제 #40
0
파일: Inet.cs 프로젝트: jsakamoto/bjd5
 static public List<String> RecvLines(SockTcp cl,int sec,ILife iLife){
     var lines = new List<string>();
     while (true) {
         var buf = cl.LineRecv(sec, iLife);
         if (buf == null)
             break;
         if (buf.Length==0)
             break;
         var s = Encoding.ASCII.GetString(TrimCrlf(buf));
         //if (s == "")
         //    break;
         lines.Add(s);
     }
     return lines;
 } 
예제 #41
0
파일: Data.cs 프로젝트: jsakamoto/bjd5
        //通常はこれを使用する
        public bool Recv(SockTcp sockTcp, int sec,Logger logger, ILife iLife)
        {
            var dtLast = DateTime.Now; //受信が20秒無かった場合は、処理を中断する
            while (iLife.IsLife()){
                if (dtLast.AddSeconds(sec) < DateTime.Now){
                    return false; //タイムアウト
                }
                var len = sockTcp.Length();
                if (len == 0){
                    continue;
                }
                var buf = sockTcp.Recv(len, sec, iLife);
                if (buf == null){
                    return false; //切断された
                }
                dtLast = DateTime.Now;

                var recvStatus = Append(buf);

                if (recvStatus == RecvStatus.Limit){
                    //サイズ制限
                    if (logger != null){
                        logger.Set(LogKind.Secure, sockTcp, 7, string.Format("Limit:{0}KByte", _sizeLimit));
                    }
                    sockTcp.AsciiSend("552 Requested mail action aborted: exceeded storage allocation");
                    return false;
                }
                if (recvStatus == RecvStatus.Finish){
                    return true;
                }
            }
            return false;
        }
예제 #42
0
파일: CacheBase.cs 프로젝트: jsakamoto/bjd5
 //        abstract public long GetInfo(ref List<CacheInfo> infoList, int sleep, ref bool life);//キャッシュ情報取得
 public abstract long GetInfo(ref List<CacheInfo> infoList, int sleep, ILife iLife);
예제 #43
0
파일: ProxyHttp.cs 프로젝트: jsakamoto/bjd5
 //サーバ側からの受信
 bool RecvServer(ILife iLife)
 {
     for (int i = _indexRecv; iLife.IsLife() && i < _ar.Count; i++) {
         if (!_ar[i].RecvServer(iLife)) {
             Proxy.Logger.Set(LogKind.Debug, null, 999, "[HTTP] Break RecvServer()");
             return false;
         }
         //サーバ側からの受信が完了しているかどうかの確認
         if (_ar[i].SideState(CS.Server) != HttpSideState.ServerSideRecvBody)
             break;
         //送信が完了しているばあは、次のデータオブジェクトの処理に移る
         _indexRecv++;
     }
     return true;
 }
예제 #44
0
파일: ProxySsl.cs 프로젝트: jsakamoto/bjd5
 bool RecvServer(ILife iLife)
 {
     if(!RecvBuf(CS.Server,iLife))
         return false;
     return true;
 }
예제 #45
0
파일: ProxySsl.cs 프로젝트: jsakamoto/bjd5
        //データの受信
        //パラメータ cs CS.SERVER を設定した場合、buf[CS.SERVER]を処理対象とし、クライアント側に送信する
        bool RecvBuf(CS cs, ILife iLife)
        {
            SockTcp sock = Proxy.Sock(cs);
            if(sock == null)//サーバ側未接続
                return true;

            var len = sock.Length();
            if(len == 0)
                return true;
            var b = sock.Recv(len,Proxy.OptionTimeout,iLife);
            if(b == null)
                return false;
            _oneObj.Body[cs].Add(b);
            _lastRecvServer = DateTime.Now.Ticks;
            return true;
        }
예제 #46
0
파일: FtpTunnel.cs 프로젝트: jsakamoto/bjd5
        //protected override byte[] AssumptionLine(byte[] buf,ILife iLife) {
        byte[] AssumptionLine(byte[] buf,ILife iLife)
        {
            //stringに変換してから処理する
            var str = Encoding.ASCII.GetString(buf);

            Logger.Set(LogKind.Detail, null, 7, str);

            var index = str.IndexOf(" ");
            if (index < 0)
                goto end;

            var cmdStr = str.Substring(0, index);
            var paramStr = str.Substring(index + 1);

            if (cmdStr == "227"){
                //PASVに対するレスポンス

                //**********************************************************************
                // 「PASV 192.168.22.102,23,15」コマンドからサーバ側の情報を取得する
                //**********************************************************************
                var tmp2 = paramStr.Split('(', ')');
                if (tmp2.Length != 3){
                    Logger.Set(LogKind.Error, null, 5, str);
                    goto end;
                }
                string[] tmp = tmp2[1].Split(',');
                if (tmp.Length != 6){
                    Logger.Set(LogKind.Error, null, 6, str);
                    goto end;
                }
                var connectIp = new Ip(string.Format("{0}.{1}.{2}.{3}", tmp[0], tmp[1], tmp[2], tmp[3]));
                var connectPort = Convert.ToInt32(tmp[4])*256 + Convert.ToInt32(tmp[5]);

                //**********************************************************************
                // クライアント側用のListenソケットを生成する
                //**********************************************************************
                var listenIp = Sock[CS.Client].LocalIp;
                // 利用可能なデータポートの選定
                int listenPort = 0;
                while (iLife.IsLife()){
                    _dataPort++;
                    if (SockServer.IsAvailable(_kernel, listenIp, _dataPort)){
                        listenPort = _dataPort;
                        break;
                    }
                }

                //**********************************************************************
                // クライアント側に送る227レスポンスを生成する
                //**********************************************************************
                str = string.Format("227 Entering Passive Mode ({0},{1},{2},{3},{4},{5})\r\n", listenIp.IpV4[0], listenIp.IpV4[1], listenIp.IpV4[2], listenIp.IpV4[3], listenPort/256, listenPort%256);
                buf = Encoding.ASCII.GetBytes(str);

                //データスレッドの準備
                if (_dataTunnel != null){
                    _dataTunnel.Dispose();
                }
                _dataTunnel = new DataTunnel(_kernel, Logger, listenIp, listenPort, connectIp, connectPort,this);
                _dataTunnel.Start();
                Thread.Sleep(3); //Listenが完了してから 227を送信する

            } else if (cmdStr == "226") { //Transfer complete.
                //_dataTunnel.WaitComplate();
                //Thread.Sleep(10);
                //_dataTunnel.Stop();
            } else if (cmdStr.ToUpper() == "PORT") {

                //**********************************************************************
                //「PORT 192.168.22.102,23,15」コマンドからクライアント側の情報を取得する
                //**********************************************************************
                var tmp = paramStr.Split(',');
                if (tmp.Length != 6) {
                    Logger.Set(LogKind.Error, null, 4, str);
                    goto end;
                }
                var connectIp = new Ip(string.Format("{0}.{1}.{2}.{3}", tmp[0], tmp[1], tmp[2], tmp[3]));
                var connectPort = Convert.ToInt32(tmp[4]) * 256 + Convert.ToInt32(tmp[5]);

                //**********************************************************************
                // サーバ側用のListenソケットを生成する
                //**********************************************************************
                var listenIp = Sock[CS.Server].LocalIp;
                // 利用可能なデータポートの選定
                int listenPort = 0;
                while (iLife.IsLife()){
                    _dataPort++;
                    if (SockServer.IsAvailable(_kernel,listenIp,_dataPort)){
                        listenPort = _dataPort;
                        break;
                    }
                }
                //**********************************************************************
                // サーバ側に送るPORTコマンドを生成する
                //**********************************************************************
                //置き換えたPORTコマンドをセットする
                str = string.Format("PORT {0},{1},{2},{3},{4},{5}\r\n", listenIp.IpV4[0], listenIp.IpV4[1], listenIp.IpV4[2], listenIp.IpV4[3], listenPort / 256, listenPort % 256);
                buf = Encoding.ASCII.GetBytes(str);

                //データスレッドの準備
                if (_dataTunnel != null) {
                    _dataTunnel.Dispose();
                }
                _dataTunnel = new DataTunnel(_kernel, Logger, listenIp, listenPort, connectIp, connectPort,this);
                _dataTunnel.Start();
                Thread.Sleep(3); //Listenが完了してから PORTを送信する
            }
            end:
            return buf;
        }
예제 #47
0
파일: SockTcp.cs 프로젝트: jsakamoto/bjd5
        //1行受信
        //切断・タイムアウトでnullが返される
        public byte[] LineRecv(int sec, ILife iLife)
        {
            var tout = new util.Timeout(sec);

            while (iLife.IsLife()){
                //Ver5.1.6
                if (_sockQueue.Length == 0){
                    Thread.Sleep(100);
                }
                byte[] buf = _sockQueue.DequeueLine();
                //noEncode = false;//テキストである事が分かっている
                Trace(TraceKind.Recv, buf, false);
                if (buf.Length != 0){
                    //Ver5.8.6 Java fix
                    tout.Update(); //タイムアウトの更新
                    return buf;
                }
                if (SockState != SockState.Connect){
                    return null;
                }
                if (tout.IsFinish()){
                    return null; //タイムアウト
                }
                Thread.Sleep(1);
            }
            return null;
        }
예제 #48
0
파일: SockTcp.cs 프로젝트: jsakamoto/bjd5
 // 【1行受信】
 //切断されている場合、nullが返される
 //public string AsciiRecv(int timeout, OperateCrlf operateCrlf, ILife iLife) {
 public string AsciiRecv(int timeout, ILife iLife)
 {
     var buf = LineRecv(timeout, iLife);
     return buf == null ? null : Encoding.ASCII.GetString(buf);
 }
예제 #49
0
파일: ProxyHttp.cs 프로젝트: jsakamoto/bjd5
 //サーバ側への送信
 bool SendServer(ILife iLife)
 {
     for (int i = _indexServer; iLife.IsLife() && i < _ar.Count; i++) {
         //次のオブジェクトの接続先が現在接続中のサーバと違う場合
         if (Proxy.Sock(CS.Server) != null && _ar[i].HostName != Proxy.HostName) {
             //既存のプロキシ処理が完了するまで、次のサーバ送信(リクエスト送信)は待機となる
             if (i < _indexClient)
                 return true;
         }
         if (!_ar[i].SendServer(iLife)) {
             return false;
         }
         _indexServer++;
     }
     return true;
 }
예제 #50
0
파일: ProxyHttp.cs 프로젝트: jsakamoto/bjd5
        //クライアント側への送信
        bool SendClient(ILife iLife)
        {
            for (int i = _indexClient; iLife.IsLife() && i < _ar.Count; i++) {
                if (!_ar[i].SendClient(iLife)) {
                    return false;
                }
                //クライアントへの送信が完了しているかどうかの確認
                if (_ar[i].SideState(CS.Client) != HttpSideState.ClientSideSendBody) {
                    break;
                }
                //送信が完了している場合は、次のデータオブジェクトの処理に移行する
                //proxy.Logger.Set(LogKind.Debug,null,999,string.Format("■indexClient {0}->{1}",indexClient,indexClient + 1));

                //キャッシュが可能な場合は、ここでキャッシュされる
                _ar[_indexClient].CacheWrite(_cache);
                //ここでオブジェクトは破棄される
                _ar[_indexClient].Dispose();

                _indexClient++;

            }
            return true;
        }
예제 #51
0
파일: SockTcp.cs 프로젝트: jsakamoto/bjd5
        //受信<br>
        //切断・タイムアウトでnullが返される
        public byte[] Recv(int len, int sec, ILife iLife)
        {
            var tout = new util.Timeout(sec);

            var buffer = new byte[0];
            try{
                if (len <= _sockQueue.Length){
                    // キューから取得する
                    buffer = _sockQueue.Dequeue(len);

                } else{
                    while (iLife.IsLife()){
                        Thread.Sleep(0);
                        if (0 < _sockQueue.Length){
                            //Java fix
                            tout.Update(); //少しでも受信があった場合は、タイムアウトを更新する

                            //size=受信が必要なバイト数
                            int size = len - buffer.Length;

                            //受信に必要なバイト数がバッファにない場合
                            if (size > _sockQueue.Length){
                                size = _sockQueue.Length; //とりあえずバッファサイズ分だけ受信する
                            }
                            byte[] tmp = _sockQueue.Dequeue(size);
                            buffer = Bytes.Create(buffer, tmp);

                            //Java fix Ver5.8.2
                            if (buffer.Length != 0){
                                break;
                            }
                        } else{
                            if (SockState != SockState.Connect){
                                return null;
                            }
                            Thread.Sleep(10);
                        }
                        if (tout.IsFinish()){
                            buffer = _sockQueue.Dequeue(len); //タイムアウト
                            break;
                        }
                    }
                }
            } catch (Exception){
                //ex.printStackTrace();
                return null;
            }
            Trace(TraceKind.Recv, buffer, false);

            return buffer;
        }
예제 #52
0
파일: ProxyFtp.cs 프로젝트: jsakamoto/bjd5
        //bool WaitLine(string cmd,ref bool life) {
        //    string cmdStr = "";
        //    string paramStr = "";
        //    string lastStr = "";
        //    while(life) {
        //        if(!server.WaitLine(proxy.Sock(CS.Server),ref cmdStr,ref paramStr)) {
        //            proxy.Sock(CS.Client).AsciiSend(lastStr);
        //            return false;
        //        }
        //        if (cmdStr == cmd)
        //            return true;
        //        lastStr = cmdStr + " " + paramStr;
        //        //Ver5.3.0 レスポンスコードが500番台(エラー)の場合、処理を中断する
        //        if (cmdStr[cmdStr.Length - 1] != '-') {
        //            //Ver5.6.3 最後が-で終わらない場合に例外が発生していた問題に対処
        //            //try {
        //            //    if (Int32.Parse(cmdStr) / 100 == 5) {
        //            //        proxy.Sock(CS.Client).AsciiSend(lastStr);
        //            //        return false;
        //            //    }
        //            //} catch {
        //            //    return false;
        //            //}
        //            int d = 0;
        //            if(Int32.TryParse(cmdStr,out d)){
        //                if(d/100==5){
        //                    proxy.Sock(CS.Client).AsciiSend(lastStr);
        //                    return false;
        //                }
        //            }
        //        }
        //    }
        //    return false;
        //}
        bool WaitLine(string cmd, ref string paramStr,ILife iLife)
        {
            string cmdStr = "";
            //string paramStr = "";

            string lastStr = "";

            while (iLife.IsLife()) {
                if (!_server.WaitLine(Proxy.Sock(CS.Server), ref cmdStr, ref paramStr)) {
                    Proxy.Sock(CS.Client).AsciiSend(lastStr);
                    return false;
                }

                if (cmdStr == cmd)
                    return true;

                lastStr = cmdStr + " " + paramStr;

                //Ver5.3.0 レスポンスコードが500番台(エラー)の場合、処理を中断する
                if (cmdStr[cmdStr.Length - 1] != '-') {
                    //Ver5.6.3 最後が-で終わらない場合に例外が発生していた問題に対処
                    //try {
                    //    if (Int32.Parse(cmdStr) / 100 == 5) {
                    //        proxy.Sock(CS.Client).AsciiSend(lastStr);
                    //        return false;
                    //    }
                    //} catch {
                    //    return false;
                    //}
                    int d;
                    if (Int32.TryParse(cmdStr, out d)) {
                        if (d / 100 == 5) {
                            Proxy.Sock(CS.Client).AsciiSend(lastStr);
                            return false;
                        }
                    }
                }
            }

            return false;
        }
예제 #53
0
파일: ProxySsl.cs 프로젝트: jsakamoto/bjd5
        //プロキシ処理
        public override bool Pipe(ILife iLife)
        {
            if(!RecvClient(iLife))//クライアントからの受信
                return false;
            if(!SendServer(iLife))//サーバへの送信
                return false;
            if(!RecvServer(iLife))//サーバからの受信
                return false;
            if(!SendClient())//クライアントへの送信
                return false;

            if(Proxy.Sock(CS.Server).SockState != SockState.Connect){
                if(IsFinish())
                    return false;
            }

            //クライアントから切断された場合は、常に処理終了
            if(Proxy.Sock(CS.Client).SockState != SockState.Connect) {
                Proxy.Logger.Set(LogKind.Debug,null,999,"□Break ClientSocket!=CONNECT");
                return false;
            }

            return true;
        }
예제 #54
0
파일: SockTcp.cs 프로젝트: jsakamoto/bjd5
        //1行のString受信
        public String StringRecv(String charsetName, int sec, ILife iLife)
        {
            try{
                byte[] bytes = LineRecv(sec, iLife);

                //[C#]
                if (bytes == null){
                    return null;
                }

                return Encoding.GetEncoding(charsetName).GetString(bytes);
            } catch (Exception e){
                Util.RuntimeException(e.Message);
            }
            return null;
        }
예제 #55
0
파일: ProxySsl.cs 프로젝트: jsakamoto/bjd5
 bool RecvClient(ILife iLife)
 {
     if(!RecvBuf(CS.Client,iLife))
         return false;
     return true;
 }
예제 #56
0
파일: SockTcp.cs 프로젝트: jsakamoto/bjd5
 //1行受信(ASCII)
 public String StringRecv(int sec, ILife iLife)
 {
     return StringRecv("ASCII", sec, iLife);
 }
예제 #57
0
파일: ProxySsl.cs 프로젝트: jsakamoto/bjd5
 bool SendServer(ILife iLife)
 {
     //サーバ側との接続処理
     if(!Proxy.Connect(iLife,_oneObj.Request.HostName,_oneObj.Request.Port,_oneObj.Request.RequestStr,_oneObj.Request.Protocol)) {
         Proxy.Logger.Set(LogKind.Debug,null,999,"□Break http.Connect()==false");
         return false;
     }
     //バッファに残っているデータの送信
     if(!SendBuf(CS.Client))
         return false;
     return true;
 }
예제 #58
0
파일: Document.cs 프로젝트: jsakamoto/bjd5
        //*********************************************************************
        // ���M
        //*********************************************************************
        //public void Send(bool keepAlive,ref bool life) {
        public void Send(bool keepAlive,ILife iLife)
        {
            _sendHeader.Replace("Connection", keepAlive ? "Keep-Alive" : "close");

            //�w�b�_���M
            _sockTcp.SendUseEncode(_sendHeader.GetBytes());//�w�b�_���M
            //�{�����M
            if(_body.Length>0) {
                //Ver5.0.0-b12
                //if(sendHeader.GetVal("Content-Type").ToLower().IndexOf("text")!=-1){
                var contentType = _sendHeader.GetVal("Content-Type");
                if(contentType!=null && contentType.ToLower().IndexOf("text")!=-1){
                    _body.Send(_sockTcp,true,iLife);
                    //tcpObj.SendUseEncode(body.Get());
                }else{
                    _body.Send(_sockTcp,false,iLife);
                    //tcpObj.SendNoEncode(body.Get());
                }
            }
        }
예제 #59
0
파일: Tunnel.cs 프로젝트: jsakamoto/bjd5
 //��M���̏���
 //��M������e�ɂ���ď�����s���K�v������ꍇ�́A���̃��\�b�h��I�[�o�[���C�h����
 protected virtual byte[] Assumption(byte [] buf,ILife iLife)
 {
     //�f�t�H���g�ł͏����Ȃ�
     return buf;
 }
예제 #60
0
파일: Document.cs 프로젝트: jsakamoto/bjd5
            //public bool Send(SockTcp tcpObj,bool encode,ref bool life){
            public bool Send(SockTcp tcpObj,bool encode,ILife iLife)
            {
                if(_kindBuf == KindBuf.Memory) {
                    if(encode) {
                        if(-1 == tcpObj.SendUseEncode(_doc))
                            return false;
                    } else {
                        if(-1 == tcpObj.SendNoEncode(_doc))
                            return false;
                    }
                } else {
                    using(var fs = new FileStream(_fileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)) {
                        using(var br = new BinaryReader(fs)) {
                            fs.Seek(_rangeFrom,SeekOrigin.Begin);
                            var start = _rangeFrom;
                            while(iLife.IsLife()) {
                                long size = _rangeTo - start + 1;
                                if(size > 1048560)
                                    size = 1048560;
                                if(size <= 0)
                                    break;
                                _doc = new byte[size];
                                int len = br.Read(_doc,0,(int)size);
                                if(len <= 0)
                                    break;

                                if(len != size) {
                                    var tmp = new byte[len];
                                    Buffer.BlockCopy(_doc,0,tmp,0,len);
                                    _doc = tmp;
                                }

                                if(encode) {
                                    if(-1 == tcpObj.SendUseEncode(_doc)) {
                                        return false;
                                    }
                                } else {
                                    if(-1 == tcpObj.SendNoEncode(_doc)) {
                                        return false;
                                    }
                                }
                                start += _doc.Length;
                                if(_rangeTo - start <= 0)
                                    break;
                                Thread.Sleep(1);
                            }
                            br.Close();
                        }
                        fs.Close();
                    }
                }
                return true;
            }