gateway

package
v0.0.0-...-ba645fd Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_PUSH      = 1
	OP_PUSH_ROOM = 2 // push to memebers in a room
	OP_PUSH_ALL  = 3 // push to all online members
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

func NewBucket

func NewBucket(id, workerCount int) *Bucket

type Command

type Command struct {
	RequestID string          `json:"req_id"`
	OP        string          `json:"op"`
	Data      json.RawMessage `json:"data"`
}

func CreateCommand

func CreateCommand(buf []byte) (*Command, error)

func (*Command) ToWSMessage

func (c *Command) ToWSMessage() (*WSMessage, error)

type CommandJoinData

type CommandJoinData struct {
	RoomID string `json:"room_id"`
}

type CommandLeaveData

type CommandLeaveData struct {
	RoomID string `json:"room_id"`
}

type Job

type Job struct {
	OP        int
	RoomID    string
	SessionID string
	Command   *Command
	WSMessage *WSMessage
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) AddSession

func (m *Manager) AddSession(session *WSSession)

func (*Manager) BucketBySessionID

func (m *Manager) BucketBySessionID(sessionID string) *Bucket

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(session *WSSession)

func (*Manager) JoinRoom

func (m *Manager) JoinRoom(roomID string, session *WSSession)

func (*Manager) LeaveRoom

func (m *Manager) LeaveRoom(roomID string, session *WSSession)

func (*Manager) Push

func (m *Manager) Push(sessionID string, command *Command)

func (*Manager) PushAll

func (m *Manager) PushAll(command *Command)

func (*Manager) PushRoom

func (m *Manager) PushRoom(roomID string, command *Command)

func (*Manager) SetGatewayAddr

func (m *Manager) SetGatewayAddr(gatewayAddr string)

func (*Manager) Status

func (m *Manager) Status() *Status

type Room

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

func NewRoom

func NewRoom(roomID string) *Room

type Status

type Status struct {
	OnlinePeople int64
}

func (*Status) DecreaseOnlinePeople

func (s *Status) DecreaseOnlinePeople()

func (*Status) IncreaseOnlinePeople

func (s *Status) IncreaseOnlinePeople()

type WSMessage

type WSMessage struct {
	MsgType int
	MsgData []byte
}

type WSSession

type WSSession struct {
	ID string
	// contains filtered or unexported fields
}

func NewWSSession

func NewWSSession(id string, claims identity.Claims, conn *websocket.Conn, manager *Manager, dispatcherClient dispatcherProto.DispatcherServiceClient, routerClient routerProto.RouterServiceClient, roomID string) *WSSession

func (*WSSession) Close

func (s *WSSession) Close()

Close func which closes websocket session and remove session from bucket and room.

func (*WSSession) ReadMessage

func (s *WSSession) ReadMessage() *WSMessage

func (*WSSession) SendCommand

func (s *WSSession) SendCommand(cmd *Command)

func (*WSSession) SendMessage

func (s *WSSession) SendMessage(msg *WSMessage)

func (*WSSession) StartTasks

func (s *WSSession) StartTasks()

Directories

Path Synopsis
delivery

Jump to

Keyboard shortcuts

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