Write() public method

public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
return void
        public void PacketBufferTest2()
        {
            PacketBuffer buffer = new PacketBuffer();
            buffer.Write(1);
            buffer.Write(0);
            buffer.Write(0);
            buffer.Write(5);

            buffer.BeginBufferIndex();
            uint m = 0;
            for (int i = 0; i < 4; i++)
                m += buffer.ReadUInt32();
            if (m != 6) { throw new Exception("PacketBuffer unji"); }
        }
Beispiel #2
0
 public PacketBuffer Encode(IChannel channel, object data)
 {
     var bytes = data as byte[];
     if (bytes == null)
         return null;
     var buffer = new PacketBuffer();
     buffer.Write(bytes, 0, bytes.Length);
     return buffer;
 }
Beispiel #3
0
        public PacketBuffer Encode(IChannel channel, dynamic data)
        {
            if (data.GetType() != typeof(string))
                return null;

            byte[] bytes = data;
            PacketBuffer buffer = new PacketBuffer();
            buffer.Write(bytes, 0, bytes.Length);
            return buffer;
        }
Beispiel #4
0
        // SendMessage로 보낸 메시지를 PacketBuffer형태로 변환합니다.
        public PacketBuffer Encode(IChannel channel, object data)
        {
            if (data.GetType() != typeof(byte[])) // 보내는 메시지가 byte[]가 아닐 경우 전송 취소
                return null;

            var bytes = (byte[]) data;
            var buffer = new PacketBuffer();
            buffer.Write(bytes, 0, bytes.Length); // Buffer에 bytes를 쓴다.
            return buffer;
        }
        public PacketBuffer Encode(IChannel channel, dynamic data)
        {
            if (data.GetType() != typeof(string))
                return null;

            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data);
            PacketBuffer buffer = new PacketBuffer();
            buffer.WriteUInt32((uint)bytes.Length);
            buffer.Write(bytes, 0, bytes.Length);
            return buffer;
        }
        public void PacketBufferTest1()
        {
            PacketBuffer buffer = new PacketBuffer();
            buffer.Dispose();
            try
            {

                buffer.Write(1);
            }
            catch (Exception) { return; }
            throw new Exception("Ssibal");
        }