Exemplo n.º 1
0
        /// <summary>
        /// Serialization this instance.
        /// </summary>
        public override CustomerArray <byte> Serialization()
        {
            CustomerArray <byte> b = base.Serialization();

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

            int offset = b.CurrentLength;

            offset += BitConvert.MemoryCopy((UInt64)Session.Uid, ref b, offset);
            offset += BitConvert.MemoryCopy(0, ref b, offset);        //time.
            offset += BitConvert.MemoryCopy((Int16)1, ref b, offset); // gameType.
            offset += BitConvert.MemoryCopy(mRoomType, ref b, offset);

            return(b);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deserialization the specified val and offset.
 /// </summary>
 /// <param name="val">Value.</param>
 /// <param name="offset">Offset.</param>
 public virtual int Deserialization(byte[] val, int offset)
 {
     if (val == null)
     {
         return(0);
     }
     MsgID            = BitConvert.GetInt16(val, ref offset);
     MsgType          = BitConvert.GetInt16(val, ref offset);
     MsgSeq           = BitConvert.GetInt32(val, ref offset);
     SourceType       = BitConvert.GetByte(val, ref offset);
     DestType         = BitConvert.GetByte(val, ref offset);
     DestId           = BitConvert.GetInt32(val, ref offset);
     Session.PlayerID = BitConvert.GetInt32(val, ref offset);
     if (MsgType == GlobalConstantNet.MsgResponse)
     {
         ReturnCode = BitConvert.GetInt16(val, ref offset);
     }
     return(offset);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Serialization this instance.
        /// </summary>
        public override CustomerArray <byte> Serialization()
        {
            CustomerArray <byte> b = base.Serialization();

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

            int offset = b.CurrentLength;

            offset += BitConvert.MemoryCopy((UInt64)Session.Uid, ref b, offset);
            offset += BitConvert.MemoryCopy(0, ref b, offset);
            offset += BitConvert.MemoryCopy(0, ref b, offset);
            offset += BitConvert.MemoryCopy(Name, ref b, offset);
            offset += BitConvert.MemoryCopy(Password, ref b, offset);

            return(b);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Serialization this instance.
        /// </summary>
        public override CustomerArray <byte> Serialization()
        {
            CustomerArray <byte> b = base.Serialization();

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

            int offset = b.CurrentLength;

            offset += BitConvert.MemoryCopy((UInt64)Session.Uid, ref b, offset);
            offset += BitConvert.MemoryCopy(0, ref b, offset); //time.
            offset += BitConvert.MemoryCopy((ushort)subOperation.CurrentLength, ref b, offset);
            for (int i = 0, max = subOperation.CurrentLength, j = b.CurrentLength; i < max; i++, j++)
            {
                b[j] = subOperation[i];
            }

            return(b);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Deserialization the specified val and offset.
        /// </summary>
        /// <param name="val">Value.</param>
        /// <param name="offset">Offset.</param>
        public override int Deserialization(byte[] val, int offset)
        {
            int index = base.Deserialization(val, offset);

            index += 2;                                      //gameId;
            index += 2;                                      //roomType;

            short num = BitConvert.GetInt16(val, ref index); //table num.

            tables = new CustomerArray <TableInfo>(num);
            num    = BitConvert.GetInt16(val, ref index); //player num.
            TableInfo table;

            for (int i = 0, max = tables.MaxLength; i < max; i++)
            {
                table        = new TableInfo();
                table.ID     = BitConvert.GetInt32(val, ref index);
                table.Status = BitConvert.GetUInt16(val, ref index);
                tables[i]    = table;
            }
            return(index);
        }
Exemplo n.º 6
0
            public void ReceiveData(int count, int offset)
            {
                if (count < 1)
                {
                    return;
                }

                if (index == 0)
                {
                    dataLength = BitConvert.GetInt32(Buff, ref offset);

                    if (dataLength > count)
                    {
                        //not complete.

                        //store
                        data = new List <byte>(dataLength);
                        for (int i = 0; i < count; i++)
                        {
                            data.Add(Buff [i]);
                        }
                        index = count;
                    }
                    else
                    {
                        data = new List <byte>(dataLength);
                        for (int i = 0; i < count; i++)
                        {
                            data.Add(Buff [i]);
                        }
                        //handle
                        HandData(data, dataLength);

                        //next
                        index = 0;
                        data  = null;
                        ReceiveData(count - dataLength, dataLength);
                    }
                }
                else
                {
                    if ((data.Count + count) >= dataLength)
                    {
                        int i;
                        for (i = 0, index = dataLength - data.Count; i < index; i++)
                        {
                            data.Add(Buff [i]);
                        }

                        //handle
                        HandData(data, dataLength);
                        //next
                        index = 0;
                        data  = null;
                        //ReceiveData(count - dataLength, dataLength);
                        if (count - i > 0)
                        {
                            ReceiveData(count - i, i);
                        }
                    }
                    else
                    {
                        //story
                        for (int i = 0; i < count; i++)
                        {
                            data.Add(Buff [i]);
                        }
                        index += count;
                    }
                }
            }