1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-19 10:26:10 -04:00
v2fly/common/net/packet.go

38 lines
692 B
Go

package net
import (
"github.com/v2ray/v2ray-core/common/alloc"
)
type Packet interface {
Destination() Destination
Chunk() *alloc.Buffer // First chunk of this commnunication
MoreChunks() bool
}
func NewPacket(dest Destination, firstChunk *alloc.Buffer, moreChunks bool) Packet {
return &packetImpl{
dest: dest,
data: firstChunk,
moreData: moreChunks,
}
}
type packetImpl struct {
dest Destination
data *alloc.Buffer
moreData bool
}
func (packet *packetImpl) Destination() Destination {
return packet.dest
}
func (packet *packetImpl) Chunk() *alloc.Buffer {
return packet.data
}
func (packet *packetImpl) MoreChunks() bool {
return packet.moreData
}