goio

package module
v0.0.0-...-28e954e Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: MIT Imports: 6 Imported by: 0

README

goio

A simple long-polling module.

Client: https://github.com/Kimgils/goio-client

Documentation

Index

Constants

View Source
const (
	MsgJoin      = `join`
	MsgLeave     = `leave`
	MsgBroadcast = `broadcast`
)

Variables

View Source
var GCPeriod int = 5

how many seconds to run gc

View Source
var LifeCycle int64 = 30

for client life cycle, default 30s

Functions

func Clients

func Clients() *clients

func NewClients

func NewClients() *clients

func NewRooms

func NewRooms() *rooms

func NewUsers

func NewUsers() *users

func Rooms

func Rooms() *rooms

func Run

func Run()

func SendMessage

func SendMessage(msg *Message, caller interface{})

func Users

func Users() *users

Types

type Client

type Client struct {
	Id   string
	User *User
	// contains filtered or unexported fields
}

func NewClient

func NewClient(user *User) *Client

func (*Client) IsDead

func (c *Client) IsDead() bool

func (*Client) Ping

func (c *Client) Ping()

func (*Client) ReadMessages

func (c *Client) ReadMessages() []*Message

func (*Client) SetIsDead

func (c *Client) SetIsDead()

type Message

type Message struct {
	EventName string `json:"e"` // join/leave/broadcast/connect
	Data      string `json:"d"`
	RoomId    string `json:"r"`
	CallerId  string `json:"c"`
	ClientId  string `json:"-"` // don't want to output this field
}

type Room

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

func NewRoom

func NewRoom(roomId string) *Room

func (*Room) IsDead

func (r *Room) IsDead() bool

func (*Room) UserCount

func (r *Room) UserCount() int

func (*Room) UserIds

func (r *Room) UserIds() []string

type User

type User struct {
	Id string
	// contains filtered or unexported fields
}

func (*User) AddClt

func (u *User) AddClt(clt *Client)

func (*User) AddData

func (u *User) AddData(k string, v string)

func (*User) AddRoom

func (u *User) AddRoom(room *Room)

func (*User) ClientCount

func (u *User) ClientCount() int

func (*User) DelClt

func (u *User) DelClt(clientId string)

func (*User) DelRoom

func (u *User) DelRoom(roomId string)

func (*User) GetData

func (u *User) GetData(key string) string

func (*User) IsDead

func (u *User) IsDead() bool

func (*User) Rooms

func (u *User) Rooms() map[string]*Room

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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