gochat

package module
v0.0.0-...-1cab0d4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: MIT Imports: 20 Imported by: 0

README

go-chat

go-micro chat websocket golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AcceptEvent = []string{"message", "notify", "receipt", "candidate", "sdp"}
)
View Source
var (
	Debug = true
)
View Source
var (
	// 持久化队列的平台,此值不可随意更改,否则会收不到队列消息
	MasterPlatform = "mobile"
)

Functions

func Init

func Init(opts ...sqlxt.Option) (*sqlx.DB, error)

func Map

func Map(f func(interface{}) string, items []interface{}) []string

func NewChatRepo

func NewChatRepo(db *sqlx.DB) *chatRepo

func NewWebsocketHandler

func NewWebsocketHandler(cli proto.ChatService) func(http.ResponseWriter, *http.Request)

Types

type AuthBody

type AuthBody struct {
	Id       string `json:"id"`
	Password string `json:"password"`
	Platform string `json:"platform"` // 来源平台
	Start    int64  `json:"start"`    // 同步消息开始时间
}

type Client

type Client struct {
	Id          string
	MentionName string
	Password    string
	// contains filtered or unexported fields
}

A Client represents the connection between the application to the HipChat service.

func NewClient

func NewClient(id, pass string) (*Client, error)

func NewClientWithServerInfo

func NewClientWithServerInfo(id, pass, host, path string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Join

func (c *Client) Join(roomId string) error

func (*Client) Messages

func (c *Client) Messages() <-chan *Message

Messages returns a read-only channel of Message structs. After joining a room, messages will be sent on the channel.

func (*Client) Out

func (c *Client) Out(roomId string) error

func (*Client) RequestRooms

func (c *Client) RequestRooms() error

func (*Client) RequestUsers

func (c *Client) RequestUsers() error

func (*Client) Rooms

func (c *Client) Rooms() <-chan []*Room

Rooms returns a channel of Room slices

func (*Client) Say

func (c *Client) Say(roomId, name, body string) error

func (*Client) Users

func (c *Client) Users() <-chan []*User

Users returns a channel of User slices

type Conn

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

func NewConn

func NewConn(service, id, platform string, start int64, stream proto.Chat_StreamStream) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Init

func (c *Conn) Init() error

func (*Conn) Publish

func (c *Conn) Publish(topic string, event *proto.Event) error

func (*Conn) Run

func (c *Conn) Run()

func (*Conn) Subscribe

func (c *Conn) Subscribe() (broker.Subscriber, error)

type Handler

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

func NewHandler

func NewHandler(service string, repo Repository, hub *Hub, broker broker.Broker) *Handler

func (*Handler) Join

func (h *Handler) Join(ctx context.Context, req *proto.JoinRequest, rsp *proto.JoinResponse) error

func (*Handler) Out

func (h *Handler) Out(ctx context.Context, req *proto.OutRequest, rsp *proto.OutResponse) error

func (*Handler) Register

func (h *Handler) Register(ctx context.Context, req *proto.RegisterRequest, rsp *proto.RegisterResponse) error

func (*Handler) Rooms

func (h *Handler) Rooms(ctx context.Context, req *proto.RoomsRequest, rsp *proto.RoomsResponse) error

func (*Handler) Send

func (h *Handler) Send(ctx context.Context, req *proto.SendRequest, rsp *proto.SendResponse) error

func (*Handler) Stream

func (h *Handler) Stream(ctx context.Context, req *proto.StreamRequest, stream proto.Chat_StreamStream) error

func (*Handler) Unregister

func (*Handler) Users

func (h *Handler) Users(ctx context.Context, req *proto.UsersRequest, rsp *proto.UsersResponse) error

type Hub

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

func NewHub

func NewHub(service string, broker broker.Broker) *Hub

func (*Hub) Register

func (h *Hub) Register(conn *Conn)

func (*Hub) Subscribe

func (h *Hub) Subscribe() (broker.Subscriber, error)

func (*Hub) Unregister

func (h *Hub) Unregister(conn *Conn)

type Message

type Message struct {
	From        string
	To          string
	Body        string
	Type        string
	MentionName string
}

A Message represents a message received from HipChat.

type Repository

type Repository interface {
	NewTx() (*sqlx.Tx, error)
	// 查询用户已登录客户端
	AvailableClient(uid, platform string) (*proto.Client, error)
	// 房间列表
	RequestRooms(uid string) ([]*proto.Room, error)
	// 好友列表
	RequestUsers(uid string) ([]*proto.User, error)
	// 查询用户
	GetUser(id string) (*proto.User, error)
	// 注册用户
	CreateUser(user *proto.User) error
	// 修改用户信息
	UpdateUser(user *proto.User) error
	// 注销用户
	DeleteUser(id string) error
	// TODO 按关键字搜索房间
	// TODO 获取房间信息
	GetRoom(id string) (*proto.Room, error)
	// TODO 创建房间(群聊)
	CreateRoom(room *proto.Room) error
	// TODO 更新部分群组信息
	UpdateRoom(room *proto.Room) error
	// TODO 删除房间
	DeleteRoom(roomId string) error
	// 成员列表
	Members(roomId string, onlyManager bool) ([]*proto.User, error)
	// TODO 加入房间
	Join(uid, roomId string) error
	// TODO 退出房间
	Out(uid, roomId string) error
	// 上线
	Online(uid, platform string) error
	// 下线
	Offline(uid, platform string) error
}

type Room

type Room struct {
	Id   string
	Name string
}

A Room represents a room in HipChat the Client can join to communicate with other members..

type User

type User struct {
	Id          string
	Name        string
	MentionName string
}

A User represents a member of the HipChat service.

Directories

Path Synopsis
examples
cli
srv
web
Package go_micro_srv_chat is a generated protocol buffer package.
Package go_micro_srv_chat is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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