services

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllMembers

type AllMembers struct {
	Members []string `json:"members"`
}

AllMembers contains all members uid

type Connector

type Connector struct {
	component.Base
}

Connector struct

func (*Connector) GetSessionData

func (c *Connector) GetSessionData(ctx context.Context) (*SessionData, error)

GetSessionData gets the session data

func (*Connector) NotifySessionData

func (c *Connector) NotifySessionData(ctx context.Context, data *SessionData)

NotifySessionData sets the session data

func (*Connector) SetSessionData

func (c *Connector) SetSessionData(ctx context.Context, data *SessionData) (*Response, error)

SetSessionData sets the session data

type ConnectorRemote

type ConnectorRemote struct {
	component.Base
}

ConnectorRemote is a remote that will receive rpc's

func (*ConnectorRemote) Docs added in v0.7.6

func (c *ConnectorRemote) Docs(ctx context.Context, ddd *protos.Doc) (*protos.Doc, error)

Docs returns documentation

func (*ConnectorRemote) RemoteFunc

func (c *ConnectorRemote) RemoteFunc(ctx context.Context, msg *protos.RPCMsg) (*protos.RPCRes, error)

RemoteFunc is a function that will be called remotely

type JoinResponse

type JoinResponse struct {
	Code   int    `json:"code"`
	Result string `json:"result"`
}

JoinResponse represents the result of joining room

type NewUser

type NewUser struct {
	Content string `json:"content"`
}

NewUser message will be received when new user join room

type RPCResponse

type RPCResponse struct {
	Msg string `json:"msg"`
}

RPCResponse represents a rpc message

type Response

type Response struct {
	Code int32
	Msg  string
}

Response struct

type Room

type Room struct {
	component.Base

	Stats *Stats
	// contains filtered or unexported fields
}

Room represents a component that contains a bundle of room related handler like Join/Message

func NewRoom

func NewRoom() *Room

NewRoom returns a new room

func (*Room) AfterInit

func (r *Room) AfterInit()

AfterInit component lifetime callback

func (*Room) Entry

func (r *Room) Entry(ctx context.Context, msg []byte) (*JoinResponse, error)

Entry is the entrypoint

func (*Room) GetSessionData

func (r *Room) GetSessionData(ctx context.Context) (*SessionData, error)

GetSessionData gets the session data

func (*Room) Init

func (r *Room) Init()

Init runs on service initialization

func (*Room) Join

func (r *Room) Join(ctx context.Context) (*JoinResponse, error)

Join room

func (*Room) Message

func (r *Room) Message(ctx context.Context, msg *UserMessage)

Message sync last message to all members

func (*Room) MessageRemote

func (r *Room) MessageRemote(ctx context.Context, msg *UserMessage, b bool, s string) (*UserMessage, error)

MessageRemote just echoes the given message

func (*Room) SendRPC

func (r *Room) SendRPC(ctx context.Context, msg *SendRPCMsg) (*protos.RPCRes, error)

SendRPC sends rpc

func (*Room) SetSessionData

func (r *Room) SetSessionData(ctx context.Context, data *SessionData) ([]byte, error)

SetSessionData sets the session data

type SendRPCMsg

type SendRPCMsg struct {
	ServerID string `json:"serverId"`
	Route    string `json:"route"`
	Msg      string `json:"msg"`
}

SendRPCMsg represents a rpc message

type SessionData

type SessionData struct {
	Data map[string]interface{}
}

SessionData struct

type Stats

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

Stats exports the room status

type UserMessage

type UserMessage struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

UserMessage represents a message that user sent

Jump to

Keyboard shortcuts

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