1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 01:53:36 -05:00
v2fly/common/net/packet.go

38 lines
692 B
Go
Raw Normal View History

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 {
2015-10-02 09:32:26 -04:00
return &packetImpl{
dest: dest,
data: firstChunk,
moreData: moreChunks,
}
}
2015-10-02 09:32:26 -04:00
type packetImpl struct {
dest Destination
data *alloc.Buffer
2015-10-02 09:32:26 -04:00
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
}
func (packet *packetImpl) Chunk() *alloc.Buffer {
return packet.data
}
2015-10-02 09:32:26 -04:00
func (packet *packetImpl) MoreChunks() bool {
return packet.moreData
}