tcpb

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Subcmd   int
	Unsubcmd int
	DC       meim.DataCreator
)

Functions

func AddClient

func AddClient(client *Client)

新增

func IsUserOnline

func IsUserOnline(uid int64) bool

判断用户是否在线

func Listen

func Listen(f func(*net.TCPConn), listenAddr string)

监听开始

func RemoveClient

func RemoveClient(client *Client)

移除

func Run

func Run(addr string)

这个是tcpRouter的服务器 运行

Types

type Client

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

func NewClient

func NewClient(conn *net.TCPConn) *Client

新建client

func (*Client) HandleMessage

func (client *Client) HandleMessage(msg *meim.InternalMessage)

实际消息处理

func (*Client) HandlePublish

func (client *Client) HandlePublish(msg *meim.InternalMessage)

处理发布单聊消息

func (*Client) HandleSubscribe

func (client *Client) HandleSubscribe(uid int64)

处理订阅消息

func (*Client) HandleUnsubscribe

func (client *Client) HandleUnsubscribe(uid int64)

处理取消订阅

func (*Client) Push

func (client *Client) Push()

func (*Client) Read

func (client *Client) Read()

读开始

func (*Client) Run

func (client *Client) Run()

func (*Client) Write

func (client *Client) Write()

真正写

type ClientSet

type ClientSet map[*Client]struct{}

func FindClientSet

func FindClientSet(userId int64) ClientSet

查找用户客户端

func GetClientSet

func GetClientSet() ClientSet

clone clients

func NewClientSet

func NewClientSet() ClientSet

func (ClientSet) Add

func (set ClientSet) Add(c *Client)

func (ClientSet) Clone

func (set ClientSet) Clone() ClientSet

只是浅复制

func (ClientSet) Count

func (set ClientSet) Count() int

func (ClientSet) IsMember

func (set ClientSet) IsMember(c *Client) bool

func (ClientSet) Remove

func (set ClientSet) Remove(c *Client)

type Route

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

对应每个comect的Route,记录每个comect的用户信息

func NewRoute

func NewRoute() *Route

func (*Route) AddUserID

func (route *Route) AddUserID(uid int64)

func (*Route) ContainUserID

func (route *Route) ContainUserID(uid int64) bool

func (*Route) GetUserIDs

func (route *Route) GetUserIDs() util.IntSet

func (*Route) IsUserOnline

func (route *Route) IsUserOnline(uid int64) bool

func (*Route) RemoveUserID

func (route *Route) RemoveUserID(uid int64)

type TCPBrokerClient

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

func NewTCPRouterClient

func NewTCPRouterClient(addr string, dc meim.DataCreator, subCmd, unsubCmd int) *TCPBrokerClient

func (*TCPBrokerClient) Close

func (tr *TCPBrokerClient) Close()

func (*TCPBrokerClient) Connect

func (tr *TCPBrokerClient) Connect()

func (*TCPBrokerClient) ReceiveMessage

func (tr *TCPBrokerClient) ReceiveMessage() (*meim.InternalMessage, error)

func (*TCPBrokerClient) SendMessage

func (tr *TCPBrokerClient) SendMessage(msg *meim.InternalMessage) error

func (*TCPBrokerClient) Subscribe

func (tr *TCPBrokerClient) Subscribe(uid int64)

func (*TCPBrokerClient) SyncMessage

func (tr *TCPBrokerClient) SyncMessage(msg *meim.InternalMessage) (*meim.InternalMessage, error)

func (*TCPBrokerClient) UnSubscribe

func (tr *TCPBrokerClient) UnSubscribe(uid int64)

Jump to

Keyboard shortcuts

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