chat

package module
v0.0.0-...-e9b8cd6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

README

chat

chat platform for golang

usage

nothing just watch the code, i do not want write documention.

Documentation

Index

Constants

View Source
const (
	SS_SUCC      sendStatus = iota + 1 // 发送成功
	SS_NOTONLINE                       // 不在线
)
View Source
const (
	MTP_TEXT msgType = iota + 1
	MTP_IMAGE
	MTP_AUDIO
	MTP_LOGIN // login

	MTP_NY_MSG_FAIL // msg not send
	MTP_NY_MSG_READ // msg read
	MTP_NY_MSG_SUCC // msg send success
	MTP_LOGIN_FAIL
	MTP_LOGIN_SUCC
)
View Source
const (
	MTO_RSER msgTo = iota + 1
	MTO_ROOM
)
View Source
const SECRET = "y9p0qRr6Yaf~LBBIv3WEJ6c"
View Source
const SERVER = "golang_chat_bysir"

Variables

This section is empty.

Functions

func VerifyUser

func VerifyUser(token string) (uid int64, err error)

return a user that only set id

Types

type Conn

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

type MessageIn

type MessageIn struct {
	Types msgType `json:"type,emitempty"`  // 1 text, 2 image, 3 audio
	Data  string  `json:"data,emitempty"`  // text or file path
	To    msgTo   `json:"to,emitempty"`    // 1 user,2 room
	ToId  int64   `json:"to_id,emitempty"` // user id or room id
	Id    int64   `json:"id,emitempty"`    // id应该尽量不一样, 用于通知发送了的msg的状态
}

server receive message from user

func (*MessageIn) Decode

func (p *MessageIn) Decode(d []byte) error

func (*MessageIn) Encode

func (p *MessageIn) Encode() []byte

type MessageOut

type MessageOut struct {
	Types     msgType `json:"type,emitempty"`      // 1 text, 2 image, 3 audio
	FromId    int64   `json:"from,emitempty"`      // from uid
	FromPic   string  `json:"form_pic,emitempty"`  // from headPic
	FromName  string  `json:"form_name,emitempty"` // from name
	Timestamp int64   `json:"timestamp,emitempty"` // send time
	Data      string  `json:"data,emitempty"`      // text or file path
	Id        int64   `json:"id,emitempty"`        // 这里的id是发送者发送的id
}

server send message to user

func (*MessageOut) Decode

func (p *MessageOut) Decode(d []byte) error

func (*MessageOut) Encode

func (p *MessageOut) Encode() []byte

type Receive

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

type Server

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

func (*Server) Server

func (p *Server) Server() error

type User

type User struct {
	Id      int64
	Name    string
	HeadPic string
	Login   bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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