session

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2020 newtbig Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ClOSE_ERR = errors.New("seesion close")

Functions

func NewSession

func NewSession(app module.App) module.Session

Types

type Session

type Session struct {
	IP   net.IP
	Port string

	LastHeartBeatTime time.Time
	PacketCount       uint32
	PacketCount1Min   int
	Processor         module.Processor
	// contains filtered or unexported fields
}

func (*Session) Call

func (s *Session) Call(msg *framepb.Msg) error

func (*Session) CallKick added in v0.0.9

func (s *Session) CallKick() error

func (*Session) GetProcessor

func (s *Session) GetProcessor() module.Processor

func (*Session) GetUID

func (s *Session) GetUID() uint64

func (*Session) Kick

func (s *Session) Kick() error

func (*Session) OnClose

func (s *Session) OnClose() error

func (*Session) OnInit

func (s *Session) OnInit(app module.App) error

func (*Session) OnStart

func (s *Session) OnStart(_conn module.Connect) error

func (*Session) OnStop

func (s *Session) OnStop() error

func (*Session) Save

func (s *Session) Save() error

func (*Session) SendByte

func (s *Session) SendByte(data []byte) error

func (*Session) SendMsg

func (s *Session) SendMsg(msg *framepb.Msg) error

func (*Session) SetHeartBeatTime

func (s *Session) SetHeartBeatTime(time time.Time)

func (*Session) SetUID

func (s *Session) SetUID(id uint64)

type SessionMgr

type SessionMgr struct {
	sync.Map
	// contains filtered or unexported fields
}

func GetSessionMgr

func GetSessionMgr() *SessionMgr

func (*SessionMgr) AddSession

func (sm *SessionMgr) AddSession(session *Session) bool

func (*SessionMgr) BroatCast

func (sm *SessionMgr) BroatCast(msg *framepb.Msg) error

func (*SessionMgr) Count

func (sm *SessionMgr) Count() int32

func (*SessionMgr) DelSession

func (sm *SessionMgr) DelSession(uid uint64)

func (*SessionMgr) GetSession

func (sm *SessionMgr) GetSession(uid uint64) *Session

func (*SessionMgr) Receive

func (sm *SessionMgr) Receive(msg *framepb.Msg) error

func (*SessionMgr) StopAllSession added in v0.0.9

func (sm *SessionMgr) StopAllSession()

func (*SessionMgr) StopSession added in v0.0.9

func (sm *SessionMgr) StopSession(uid uint64)

Jump to

Keyboard shortcuts

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