server

package module
v0.0.0-...-4719a5c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 9 Imported by: 0

README

go-socket

simple go socket

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger() *zap.Logger

func GetSugerLogger

func GetSugerLogger() *zap.SugaredLogger

func InitLogger

func InitLogger(z *zap.Logger)

func NewLogger

func NewLogger()

Types

type Server

type Server struct {
	Ip           string
	Port         int
	ClientPool   SessionPool
	IdleDuration time.Duration
	OnMessage    func(*Session, []byte)
	OnError      func(*Session, error)
	OnSpliter    func([]byte, bool) (int, []byte, error)
	Stop         bool
}

func (*Server) CloseServer

func (s *Server) CloseServer()

func (*Server) HandleConnection

func (s *Server) HandleConnection(c net.Conn)

func (*Server) Start

func (s *Server) Start()

type Session

type Session struct {
	Id uuid.UUID
	// contains filtered or unexported fields
}

func (*Session) Close

func (s *Session) Close(reason string)

func (*Session) Send

func (s *Session) Send(b []byte)

type SessionPool

type SessionPool struct {
	Source       sync.Map
	Add          chan *Session
	Delete       chan *Session
	SessionCount int
	Close        bool
}

func (*SessionPool) AddSession

func (s *SessionPool) AddSession(c *Session)

func (*SessionPool) CheckConnection

func (s *SessionPool) CheckConnection()

func (*SessionPool) DeleteSession

func (s *SessionPool) DeleteSession(c *Session)

func (*SessionPool) GetSessionCount

func (s *SessionPool) GetSessionCount() int

func (*SessionPool) Manager

func (s *SessionPool) Manager()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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