models

package
v0.0.0-...-b15ad40 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RoomChat

func RoomChat(r *Room) http.HandlerFunc

RoomChat take a room, return a HandlerFunc, responsible for send & receive websocket data for all channels

func SendMessageToTopic

func SendMessageToTopic(topicName string, message []byte) error

SendMessageToTopic send Message to NSQ topic

Types

type Channel

type Channel struct {
	ID        bson.ObjectId `json:"id" bson:"_id"`
	Name      string        `json:"name" bson:"name"`
	CreatedBy string        `json:"created_by" bson:"created_by"`
}

Channel holds information about one specific channel in the room

type Client

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

Client represents a user connect to a room, one user may have many devices to chat, so it should not be the same as user

type Message

type Message struct {
	Name      string    `json:"name" bson:"name"`
	Body      string    `json:"body" bson:"body"`
	Channel   string    `json:"channel" bson:"channel"`
	User      string    `json:"user" bson:"user"`
	Timestamp time.Time `json:"timestamp,omitempty" bson:"timestamp"`
}

Message represents a single message which a client sent to a room (same meaning as a user send to a channel)

type NsqReader

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

NsqReader represents a NSQ channel below topic Chat

func (*NsqReader) HandleMessage

func (nr *NsqReader) HandleMessage(msg *nsq.Message) error

HandleMessage pushes messages from NSQ to Client, is used by AddHandler() function

type Room

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

Room represents a room to chat

func NewRoomChan

func NewRoomChan() *Room

NewRoomChan creates a new room for clients to join

type User

type User struct {
	ID                string    `json:"id" bson:"_id"`
	Provider          string    `json:"provider" bson:"provider"`
	Email             string    `json:"email" bson:"email"`
	Name              string    `json:"name" bson:"name"`
	FirstName         string    `json:"first_name" bson:"first_name"`
	LastName          string    `json:"last_name" bson:"last_name"`
	NickName          string    `json:"nick_name" bson:"nick_name"`
	Description       string    `json:"description" bson:"description"`
	UserID            string    `json:"user_id" bson:"user_id"`
	AvatarURL         string    `json:"avatar_url" bson:"avatar_url"`
	Location          string    `json:"location" bson:"location"`
	AccessToken       string    `json:"access_token" bson:"access_token"`
	AccessTokenSecret string    `json:"access_token_secret" bson:"access_token_secret"`
	RefreshToken      string    `json:"refresh_token" bson:"refresh_token"`
	ExpiresAt         time.Time `json:"expires_at" bson:"expires_at"`
	CreatedAt         time.Time `json:"created_at" bson:"created_at"`
	Active            bool      `json:"active" bson:"active"`
}

User hold information about an user

type UserKey

type UserKey int

UserKey is key to save user to context

Jump to

Keyboard shortcuts

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