chat

package
v0.0.0-...-71950a0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.0.1"

Variables

This section is empty.

Functions

func ParseConfig

func ParseConfig(file string, c *Config) error

func Run

func Run()

Types

type Client

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

func (*Client) Join

func (cli *Client) Join()

func (*Client) Leave

func (cli *Client) Leave()

func (*Client) ReadMessage

func (cli *Client) ReadMessage()

type Config

type Config struct {
	Host    string
	Uri     string
	Static  string
	Timeout time.Duration
}

type Message

type Message struct {
	MT  MessageType
	Msg string
}

type MessageType

type MessageType int
const (
	// BroadcastMessage 广播消息(正常的�消息)
	MT_Broadcast MessageType = iota + 1

	// ConnectedMessage 上线通知
	MT_Connected

	// DisconnectedMessage 下线通知
	MT_Disconnected

	// HeartBeatMessage 心跳消息
	MT_HeartBeat

	// SystemMessage 系统消息
	MT_System

	// BreakMessage 服务断开链接通知(服务端关闭)
	MT_Break
)

func (MessageType) String

func (mt MessageType) String() string

type Response

type Response struct {
	MT     MessageType
	Msg    string
	User   string
	SendAt string
}

type Room

type Room struct {
	persist.Persister
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(ps persist.Persister) *Room

func (*Room) Broadcast

func (room *Room) Broadcast(cli *Client, msg *Message)

func (*Room) BuildJoin

func (room *Room) BuildJoin(cli *Client)

func (*Room) BuildLeave

func (room *Room) BuildLeave(cli *Client)

func (*Room) BuildResponse

func (room *Room) BuildResponse(resp *Response)

func (*Room) ServeHTTP

func (room *Room) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Room) Work

func (room *Room) Work()

Jump to

Keyboard shortcuts

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