Example #1
0
        internal Session(TcpClient client)
        {
            // Get a stream object for reading and writing
            stream = client.GetStream();

            readPacket = new ReadPacket(stream);
            writePacket = new WritePacket(stream);
            callback = new ReadPacket.CallbackDelegate(HandlePacket);
        }
 /// <summary>
 /// Answer to the client.
 /// </summary>
 /// <param name="packet"></param>
 internal void Answer(WritePacket packet)
 {
     packet.Init();
     packet.Type = Packet.NEGOT_PACKET;
     for (int i = 0; i < records.Count; i++)
     {
         Record record = records[i];
         packet.WriteByte(record.type);
         packet.WriteBeShort(record.offset);
         packet.WriteBeShort(record.size);
     }
     packet.WriteByte(0xFF);
     for (int i = 0; i < records.Count; i++)
     {
         Record record = records[i];
         packet.WriteBytes(record.data);
     }
     packet.Send();
 }