services

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 9 Imported by: 3

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
	// contains filtered or unexported fields
}

Connector struct

func NewConnector

func NewConnector(app pitaya.Pitaya) *Connector

NewConnector ctor

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) (*protos.Response, error)

SetSessionData sets the session data

type ConnectorRemote

type ConnectorRemote struct {
	component.Base
	// contains filtered or unexported fields
}

ConnectorRemote is a remote that will receive rpc's

func NewConnectorRemote

func NewConnectorRemote(app pitaya.Pitaya) *ConnectorRemote

NewConnectorRemote ctor

func (*ConnectorRemote) Descriptor added in v2.0.3

func (*ConnectorRemote) Docs

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 *protos.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(app pitaya.Pitaya) *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) (*protos.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) (*protos.JoinResponse, error)

Join room

func (*Room) Message

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

Message sync last message to all members

func (*Room) MessageRemote

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

MessageRemote just echoes the given message

func (*Room) SendRPC

func (r *Room) SendRPC(ctx context.Context, msg *protos.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