2015-09-22 08:45:03 -04:00
|
|
|
package net
|
|
|
|
|
|
|
|
type Packet interface {
|
|
|
|
Destination() Destination
|
|
|
|
Chunk() []byte // First chunk of this commnunication
|
|
|
|
MoreChunks() bool
|
|
|
|
}
|
|
|
|
|
2015-10-02 09:32:26 -04:00
|
|
|
func NewPacket(dest Destination, firstChunk []byte, moreChunks bool) Packet {
|
|
|
|
return &packetImpl{
|
|
|
|
dest: dest,
|
|
|
|
data: firstChunk,
|
|
|
|
moreData: moreChunks,
|
2015-09-22 08:45:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 09:32:26 -04:00
|
|
|
type packetImpl struct {
|
|
|
|
dest Destination
|
|
|
|
data []byte
|
|
|
|
moreData bool
|
2015-09-28 08:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-10-02 09:32:26 -04:00
|
|
|
func (packet *packetImpl) Destination() Destination {
|
|
|
|
return packet.dest
|
2015-09-22 08:45:03 -04:00
|
|
|
}
|
|
|
|
|
2015-10-02 09:32:26 -04:00
|
|
|
func (packet *packetImpl) Chunk() []byte {
|
2015-09-22 08:45:03 -04:00
|
|
|
return packet.data
|
|
|
|
}
|
|
|
|
|
2015-10-02 09:32:26 -04:00
|
|
|
func (packet *packetImpl) MoreChunks() bool {
|
|
|
|
return packet.moreData
|
2015-09-22 08:45:03 -04:00
|
|
|
}
|