photon_spectator

package module
v0.0.0-...-94fe760 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2017 License: Apache-2.0 Imports: 6 Imported by: 2

README

Photon Observer

Build Status GoDoc

Tools for working with the Photon protocol via gopacket.

Documentation

Index

Constants

View Source
const (
	NilType       = 42
	Int8Type      = 98
	Float32Type   = 102
	Int32Type     = 105
	Int16Type     = 107
	Int64Type     = 108
	StringType    = 115
	BooleanType   = 111
	SliceInt8Type = 120
	SliceType     = 121
)
View Source
const (
	// Command types
	AcknowledgeType          = 1
	ConnectType              = 2
	VerifyConnectType        = 3
	DisconnectType           = 4
	PingType                 = 5
	SendReliableType         = 6
	SendUnreliableType       = 7
	SendReliableFragmentType = 8
	// Message types
	OperationRequest = 2

	EventDataType     = 4
	OperationResponse = 7
)
View Source
const (
	PhotonCommandHeaderLength = 12
)

Variables

View Source
var PhotonLayerType = gopacket.RegisterLayerType(5056,
	gopacket.LayerTypeMetadata{
		Name:    "PhotonLayerType",
		Decoder: gopacket.DecodeFunc(decodePhotonPacket)})

Functions

This section is empty.

Types

type FragmentBuffer

type FragmentBuffer struct {
	// contains filtered or unexported fields
}

Provides a LRU backed buffer which will assemble ReliableFragments into a single PhotonCommand with type ReliableMessage

func NewFragmentBuffer

func NewFragmentBuffer() *FragmentBuffer

Makes a new instance of a FragmentBuffer

func (*FragmentBuffer) Offer

Offers a message to the buffer. Returns nil when no new commands could be assembled from the buffer's contents.

type PhotonCommand

type PhotonCommand struct {
	// Header
	Type                   uint8
	ChannelID              uint8
	Flags                  uint8
	ReservedByte           uint8
	Length                 int32
	ReliableSequenceNumber int32

	// Body
	Data []byte
}

func (PhotonCommand) ReliableFragment

func (c PhotonCommand) ReliableFragment() (msg ReliableFragment, err error)

Returns a structure containing the fields of a reliable fragment Errors if the type is not SendReliableFragmentType.

func (PhotonCommand) ReliableMessage

func (c PhotonCommand) ReliableMessage() (msg ReliableMessage, err error)

Returns a structure containing the fields of a reliable message. Errors if the type is not SendReliableType.

type PhotonLayer

type PhotonLayer struct {
	// Header
	PeerID       uint16
	CrcEnabled   uint8
	CommandCount uint8
	Timestamp    uint32
	Challenge    int32

	// Commands
	Commands []PhotonCommand
	// contains filtered or unexported fields
}

func (PhotonLayer) LayerContents

func (p PhotonLayer) LayerContents() []byte

func (PhotonLayer) LayerPayload

func (p PhotonLayer) LayerPayload() []byte

func (PhotonLayer) LayerType

func (p PhotonLayer) LayerType() gopacket.LayerType

type ReliableFragment

type ReliableFragment struct {
	SequenceNumber int32
	FragmentCount  int32
	FragmentNumber int32
	TotalLength    int32
	FragmentOffset int32

	Data []byte
}

type ReliableMessage

type ReliableMessage struct {
	// Header
	Signature uint8
	Type      uint8

	// OperationRequest
	OperationCode uint8

	// EventData
	EventCode uint8

	// OperationResponse
	OperationResponseCode uint16
	OperationDebugByte    uint8

	ParamaterCount int16
	Data           []byte
}

type ReliableMessageParamaters

type ReliableMessageParamaters map[string]interface{}

func DecodeReliableMessage

func DecodeReliableMessage(msg ReliableMessage) (ReliableMessageParamaters, error)

Converts the paramaters of a reliable message into a hash situable for use in hashmap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL