sockets

package
v0.0.0-...-3f08e25 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 16 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

当程序要退出的时候,断开所有的连接

func Stop

func Stop()

关闭

Types

type App

type App struct {
	BroadcastMessageChan chan string // 广播消息channel
	// contains filtered or unexported fields
}

func (*App) ConsumeMessageLoop

func (app *App) ConsumeMessageLoop()

不断的消费

type Client

type Client struct {
	RemoteAddr string `json:"remote_addr"` // 远端的地址
	IsActive   bool   `json:"is_active"`   // 是否是有效的,断开的时候需要设置为false
	// contains filtered or unexported fields
}

连接的客户端

func (*Client) ReadeLoop

func (client *Client) ReadeLoop()

接收消息

func (*Client) SendMessage

func (client *Client) SendMessage(messageType int, data []byte, needPacket bool) (err error)

发送消息 messageType: 消息类型 data []byte: 发送小消息内容 needPacket bool: 是否需要封装一下包,有时候可自行封装

type Message

type Message struct {
	RemoteAddr string // 客户端的地址
	Data       []byte // 接收到的消息内容
}

客户端发送的消息

type MessageEvent

type MessageEvent struct {
	Category string `json:"category"` // 消息分类
	Data     string `json:"data"`     // 数据
}

消息事件 通过消息来判断事件的类型,比如:message, createJob, jobExecute, tryLock, leaseLock, releaseLock,

type WatchJobsHandler

type WatchJobsHandler struct {
	KeyDir string // 监听的key目录
	// contains filtered or unexported fields
}

监听etcd中jobs的变化

func (*WatchJobsHandler) HandlerGetResponse

func (watch *WatchJobsHandler) HandlerGetResponse(response *clientv3.GetResponse)

func (*WatchJobsHandler) HandlerWatchChan

func (watch *WatchJobsHandler) HandlerWatchChan(watchChan clientv3.WatchChan)

处理watch

type WatchKillHandler

type WatchKillHandler struct {
	KeyDir string // 监听的key目录
	// contains filtered or unexported fields
}

func (*WatchKillHandler) HandlerGetResponse

func (watch *WatchKillHandler) HandlerGetResponse(response *clientv3.GetResponse)

func (*WatchKillHandler) HandlerWatchChan

func (watch *WatchKillHandler) HandlerWatchChan(watchChan clientv3.WatchChan)

type WebsocketController

type WebsocketController struct {
	Ctx     iris.Context
	Session sessions.Session
}

mvc websocket controller

func (*WebsocketController) Get

func (c *WebsocketController) Get(ctx iris.Context)

func (*WebsocketController) GetClient

func (c *WebsocketController) GetClient(ctx iris.Context)

socket连接

func (*WebsocketController) GetClients

func (c *WebsocketController) GetClients(ctx iris.Context)

查看当前系统中的锁

Jump to

Keyboard shortcuts

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