Exemple #1
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);

            Session.PlayerID = BitConvert.GetInt32(val, ref index);
            Session.DialogId = Session.PlayerID;
            return(index);
        }
Exemple #2
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; // gameType.
            Session.RoomId     = BitConvert.GetInt32(val, ref index);
            index             += 4; //serverID.
            Session.ServerPort = BitConvert.GetUInt16(val, ref index);
            Session.ServerIP   = BitConvert.GetString(val, ref index);
            return(index);
        }
Exemple #3
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);

            tableId = BitConvert.GetInt32(val, ref index);
            SeatId  = BitConvert.GetInt32(val, ref index);
            if (ReturnCode == 0)
            {
                Session.TableID = tableId;
                Session.SeatID  = SeatId;
            }
            return(index);
        }
 /// <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);
 }
Exemple #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);
        }
Exemple #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;
                    }
                }
            }