Example #1
0
 protected override void WriteData(Stream buffer)
 {
     buffer.WriteShortByteArray(QueryId);
     buffer.WriteShort((short)Parameters.Count);
     foreach (var prm in Parameters)
         buffer.WriteByteArray(prm);
     buffer.WriteShort((short)CqlConsistency);
 }
Example #2
0
        /// <summary>
        /// Writes the data to buffer.
        /// </summary>
        /// <param name="buffer"> The buffer. </param>
        protected override void WriteData(Stream buffer)
        {
            if(ProtocolVersion == 1)
            {
                throw new ProtocolException(ProtocolVersion, ErrorCode.Protocol, "Batch frames are supported from Cassandra Version 2.0.0 and up.");
            }

            buffer.WriteByte((byte)Type);
            buffer.WriteShort((ushort)Commands.Count);
            foreach(var command in Commands)
            {
                if(command.IsPrepared)
                {
                    buffer.WriteByte(1);
                    buffer.WriteShortByteArray(command.QueryId);
                }
                else
                {
                    buffer.WriteByte(0);
                    buffer.WriteLongString(command.CqlQuery);
                }

                if(command.ParameterValues != null)
                {
                    byte[][] paramValues = command.ParameterValues.Serialize(ProtocolVersion);
                    var length = (ushort)paramValues.Length;
                    buffer.WriteShort(length);
                    for(var i = 0; i < length; i++)
                    {
                        buffer.WriteByteArray(paramValues[i]);
                    }
                }
                else
                    buffer.WriteShort(0);
            }

            buffer.WriteConsistency(CqlConsistency);

            if(ProtocolVersion >= 3)
            {
                var flags = (byte)((SerialConsistency.HasValue ? 16 : 0) |
                                   (Timestamp.HasValue ? 32 : 0));

                buffer.WriteByte(flags);

                if(SerialConsistency.HasValue)
                    buffer.WriteShort((ushort)SerialConsistency.Value);

                if(Timestamp.HasValue)
                    buffer.WriteLong(Timestamp.Value.ToTimestamp());
            }
        }
Example #3
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteShort (SlotID);
 }
Example #4
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteInt (EntityID);
     aStream.WriteShort(VelX);
     aStream.WriteShort (VelY);
     aStream.WriteShort (VelZ);
 }
Example #5
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteInt (EntityID);
     aStream.WriteShort (Slot);
     aStream.WriteShort (ItemID);
     aStream.WriteShort (Damage);
 }
Example #6
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteShort (Health);
 }
Example #7
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteInt (X);
     aStream.WriteByte (Y);
     aStream.WriteInt (Z);
     aStream.WriteByte ((byte)Direction);
     aStream.WriteShort (ItemID);
     if (ItemID >= 0) {
         aStream.WriteByte (Amount);
         aStream.WriteShort (Damage);
     }
 }
Example #8
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteInt (EntityID);
     aStream.WriteShort (ItemID);
     aStream.WriteByte (Count);
     aStream.WriteShort (DamageData);
     aStream.WriteInt (X);
     aStream.WriteInt (Y);
     aStream.WriteInt (Z);
     aStream.WriteByte (Rotation);
     aStream.WriteByte (Pitch);
     aStream.WriteByte (Roll);
 }
Example #9
0
 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteInt (EntityID);
     aStream.WriteString16 (PlayerName);
     aStream.WriteInt (X);
     aStream.WriteInt (Y);
     aStream.WriteInt (Z);
     aStream.WriteByte (Rotation);
     aStream.WriteByte (Pitch);
     aStream.WriteShort (CurrentItem);
 }
Example #10
0
 protected void WriteMessageIdentifier(Stream stream) {
     stream.WriteShort(MessageIdentifier);
 }
Example #11
0
 protected void WriteKeepAlive(Stream stream) {
     stream.WriteShort(KeepAlive);
 }
Example #12
0
 protected override void WriteData(Stream buffer)
 {
     buffer.WriteLongString(Cql);
     buffer.WriteShort((short) CqlConsistency);
 }
Example #13
0
        /// <summary>
        /// Writes the query parameters.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        protected void WriteQueryParameters(Stream buffer)
        {
            buffer.WriteConsistency(CqlConsistency);

            var flags = (byte)((Parameters != null ? 1 : 0) |
                               (SkipMetaData ? 2 : 0) |
                               (PageSize.HasValue ? 4 : 0) |
                               (PagingState != null ? 8 : 0) |
                               (SerialConsistency.HasValue ? 16 : 0) |
                               (ProtocolVersion >= 3 && Timestamp.HasValue ? 32 : 0));

            buffer.WriteByte(flags);

            if(Parameters != null)
            {
                buffer.WriteShort((ushort)Parameters.Count);
                foreach(var value in Parameters)
                    buffer.WriteByteArray(value);
            }

            if(PageSize.HasValue)
                buffer.WriteInt(PageSize.Value);

            if(PagingState != null)
                buffer.WriteByteArray(PagingState);

            if(SerialConsistency.HasValue)
                buffer.WriteShort((ushort)SerialConsistency.Value);

            if(ProtocolVersion >= 3 && Timestamp.HasValue)
                buffer.WriteLong(Timestamp.Value.ToTimestamp()*1000); //convert milliseconds to microseconds
        }