예제 #1
0
        public void Import(byte[] data, int start, int count)
        {
            try
            {
                if (mCheckSize == null)
                {
                    mCheckSize = new CheckSize();

                }
                while (count > 0)
                {
                    if (!mLoading)
                    {
                        mCheckSize.Reset();
                        mStream = new System.IO.MemoryStream();
                        mLoading = true;
                    }
                    if (mCheckSize.Length == -1)
                    {
                        while (count > 0 && mCheckSize.Length == -1)
                        {
                            mCheckSize.Import(data[start]);
                            start++;
                            count--;
                        }
                    }
                    else
                    {
                        if (mCheckSize.Length > Application.PacketMaxsize)
                        {
                            Channel.Dispose();
                            "Data Overflow max length is {0}".ThrowError<Exception>(Application.PacketMaxsize);
                        }
                        if (OnImport(data, ref start, ref count))
                        {
                            mLoading = false;
                            if (this.Receive != null)
                            {
                                mStream.Position = 0;
                                PackageReceiveArgs e = new PackageReceiveArgs();
                                e.Channel = this.Channel;
                                e.Message = GetMessage(mStream);
                                Receive(this, e);
                            }
                        }
                    }
                }
            }
            catch (Exception e_)
            {
                throw e_;
            }

        }
예제 #2
0
 public void Import(byte[] data, int start, int count)
 {
     try
     {
         if (mCheckSize == null)
         {
             mCheckSize = new CheckSize();
         }
         while (count > 0)
         {
             if (!mLoading)
             {
                 mCheckSize.Reset();
                 mStream  = new System.IO.MemoryStream();
                 mLoading = true;
             }
             if (mCheckSize.Length == -1)
             {
                 while (count > 0 && mCheckSize.Length == -1)
                 {
                     mCheckSize.Import(data[start]);
                     start++;
                     count--;
                 }
             }
             else
             {
                 if (mCheckSize.Length > Application.PacketMaxsize)
                 {
                     Channel.Dispose();
                     "Data Overflow max length is {0}".ThrowError <Exception>(Application.PacketMaxsize);
                 }
                 if (OnImport(data, ref start, ref count))
                 {
                     mLoading = false;
                     if (this.Receive != null)
                     {
                         mStream.Position = 0;
                         PackageReceiveArgs e = new PackageReceiveArgs();
                         e.Channel = this.Channel;
                         e.Message = GetMessage(mStream);
                         Receive(this, e);
                     }
                 }
             }
         }
     }
     catch (Exception e_)
     {
         throw e_;
     }
 }
예제 #3
0
파일: Package.cs 프로젝트: hdxhan/IKendeLib
        public void Import(byte[] data, int start, int count)
        {
            try
            {
                if (mCheckSize == null)
                {
                    mCheckSize = new CheckSize();
                    mCheckSize.LittleEndian = LittleEndian;
                }
                while (count > 0)
                {
                    if (!mLoading)
                    {
                        mCheckSize.Reset();
                        mStream.SetLength(0);
                        mStream.Position = 0;
                        mLoading = true;
                    }
                    if (mCheckSize.Length == -1)
                    {
                        while (count > 0 && mCheckSize.Length == -1)
                        {
                            mCheckSize.Import(data[start]);
                            start++;
                            count--;
                        }
                    }
                    else
                    {
                        if (OnImport(data, ref start, ref count))
                        {
                            mLoading = false;
                            if (Receive != null)
                            {
                                mStream.Position = 0;
                                Receive(mStream);
                            }
                        }
                    }
                }
            }
            catch (Exception e_)
            {
                throw e_;
            }

        }
예제 #4
0
파일: Package.cs 프로젝트: zmm623/IKendeLib
 public void Import(byte[] data, int start, int count)
 {
     try
     {
         if (mCheckSize == null)
         {
             mCheckSize = new CheckSize();
             mCheckSize.LittleEndian = LittleEndian;
         }
         while (count > 0)
         {
             if (!mLoading)
             {
                 mCheckSize.Reset();
                 mStream.SetLength(0);
                 mStream.Position = 0;
                 mLoading         = true;
             }
             if (mCheckSize.Length == -1)
             {
                 while (count > 0 && mCheckSize.Length == -1)
                 {
                     mCheckSize.Import(data[start]);
                     start++;
                     count--;
                 }
             }
             else
             {
                 if (OnImport(data, ref start, ref count))
                 {
                     mLoading = false;
                     if (Receive != null)
                     {
                         mStream.Position = 0;
                         Receive(mStream);
                     }
                 }
             }
         }
     }
     catch (Exception e_)
     {
         throw e_;
     }
 }
예제 #5
0
파일: Package.cs 프로젝트: hdxhan/IKendeLib
 public void Reset()
 {
     mCheckSize = null;
     mLoading = false;
 }
예제 #6
0
 public void Reset()
 {
     mCheckSize = null;
     mLoading   = false;
 }