service

package
v0.0.0-...-c1e3cba Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Manager = ClientManager{
	Clients:    make(map[string]*Client),
	Broadcast:  make(chan *Broadcast),
	Reply:      make(chan *Client),
	Register:   make(chan *Client),
	Unregister: make(chan *Client),
}

Functions

func AppendAndSort

func AppendAndSort(listMe, listYou []ws.Trainer) (res []ws.Result)

func AppendList

func AppendList(list []ws.Trainer, from string) (res []ws.Result)

func FindMany

func FindMany(database string, id string, sendId string, pageSize int) []ws.Result

func InsertMsg

func InsertMsg(database string, id string, content string, read uint, expire int64) error

func WriteMessage

func WriteMessage(client *Client, msgType int, code int, content string, from string)

func WsHandler

func WsHandler(c *gin.Context)

Types

type Broadcast

type Broadcast struct {
	Client  *Client
	Message []byte
	Type    int
}

Broadcast 广播类,包括广播内容和源用户

type Client

type Client struct {
	ID     string
	SendID string
	Socket *websocket.Conn
	Send   chan []byte
}

Client 用户类

func (*Client) Read

func (c *Client) Read()

func (*Client) Write

func (c *Client) Write()

type ClientManager

type ClientManager struct {
	Clients    map[string]*Client
	Broadcast  chan *Broadcast
	Reply      chan *Client
	Register   chan *Client
	Unregister chan *Client
}

ClientManager 用户管理

func (*ClientManager) Start

func (manager *ClientManager) Start()

type Message

type Message struct {
	Sender    string `json:"sender,omitempty"`
	Recipient string `json:"recipient,omitempty"`
	Content   string `json:"content,omitempty"`
}

Message 信息转JSON (包括:发送者、接收者、内容)

type ReplyMsg

type ReplyMsg struct {
	From    string `json:"from"`
	Code    int    `json:"code"`
	Content string `json:"content"`
}

ReplyMsg 回复的消息

type SendMsg

type SendMsg struct {
	Type    int    `json:"type"`
	Content string `json:"content"`
}

SendMsg 发送的消息

type UserRegisterService

type UserRegisterService struct {
	NickName string `form:"nick_name" json:"nick_name" binding:"required,min=1,max=10"`
	Password string `form:"password" json:"password" binding:"required,min=6,max=10"`
}

func (*UserRegisterService) Register

func (us *UserRegisterService) Register() serializer.Response

Jump to

Keyboard shortcuts

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