websocket

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//PacketTypeJSON is const of packet data type json
	PacketTypeJSON int = 0
	//PacketTypeClass is const of packet data type class
	PacketTypeClass int = 1
	//PacketTypeHeartbeat is const of packet data type heartbeat
	PacketTypeHeartbeat int = 2

	//TextMessage the same as gorilla message type
	TextMessage int = 1
	//BinaryMessage the same as gorilla message type
	BinaryMessage int = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnData

type ConnData interface {
	Start()
	Stop()
	GetConnID() string
	Send(packetBody []byte)
}

ConnData is connection object which do receive and send data using gorilla websocket conn

func NewConnData

func NewConnData(co *gorillaWebsocket.Conn,
	connecLostChan chan string,
	receivePacketChan chan *ReceivePacketData,
	aliveTimeout time.Duration) (ConnData, error)

newConnData returns a new connData.

type ReceivePacketData

type ReceivePacketData struct {
	Packet      []byte
	ConnID      string
	MessageType int
}

ReceivePacketData contain parsed date which is read from connection Without packet head With data type and packet body

type SendPacketData

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

SendPacketData store receiveIDs and packet to send

type WebsocketService

type WebsocketService interface {
	Start() error
	Stop() error
	Destroy()

	Send(receiverIDs []string, sentPacket []byte) error
	Disconnect(id string) error
	GetReceivePacketChan() <-chan *ReceivePacketData
	GetLostConnIDChan() <-chan string
}

Service this is a socket manager used for followings purpose: Hold connection Read packet Write packet Send packet to chan

func NewWebsocketService

func NewWebsocketService(addresss, portt string, aesKey []byte,
	connectPoolCapacity int,
	packetChanCapacity int,
	connectionLostChanCapacity int,
	acceptTimeout time.Duration,
	aliveTimeout time.Duration) (WebsocketService, error)

NewService make a new SocketManager

Jump to

Keyboard shortcuts

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