service

package
v0.0.0-...-ee7ecfe Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

通用服务

Index

Constants

View Source
const (
	DEFAULT_CH_SIZE = 16 // 默认玩家异步消息队列大小
)

Variables

View Source
var (
	ERROR_INCORRECT_FRAME_TYPE = errors.New("incorrect frame")
	ERROR_SERVICE_NOT_BIND     = errors.New("service not bind")
)

Functions

func Add

func Add(id int32, v *Session)

func Count

func Count() int

func ForEachSend

func ForEachSend(msg network.RawMessage)

func Remove

func Remove(id int32)

func Send

func Send(id int32, msg network.RawMessage)

for async ipc, not sync

func Start

func Start(addr string, coder network.Imessage)

Types

type Agent

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

func (*Agent) Send

func (s *Agent) Send(userid int32, msg network.RawMessage, mq chan network.Data_Frame)

FIXME for async ipc

func (*Agent) Stream

func (s *Agent) Stream(stream network.Service_StreamServer) error

type Service

type Service struct {
	Config string
	Coder  network.Imessage
	// contains filtered or unexported fields
}

func (*Service) OnDestroy

func (s *Service) OnDestroy()

func (*Service) OnInit

func (s *Service) OnInit()

func (*Service) Run

func (s *Service) Run(ChClose chan bool)

type Session

type Session struct {
	MQ       chan network.Data_Frame // 返回给网关的异步消息
	Agent    *Agent                  // agent
	UserId   int32                   // 玩家ID
	Die      chan struct{}           // 会话关闭信号
	Flag     int32                   // 会话标记
	UserData map[string]interface{}  // 用户自定义sess数据
}

func Get

func Get(id int32) *Session

func New

func New(msgParser network.Imessage) *Session

func (*Session) AddData

func (s *Session) AddData(key string, data interface{})

func (*Session) DelData

func (s *Session) DelData(key string)

func (*Session) Get

func (s *Session) Get(key string) interface{}

func (*Session) IsExist

func (s *Session) IsExist(key string) bool

type SessionManger

type SessionManger struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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