chat

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

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

Go to latest
Published: Dec 5, 2014 License: MIT Imports: 6 Imported by: 0

README

gochat

Asyncronous chat engine in Go, supports websocket and HTTP longpoll APIs.

Documentation

Index

Constants

View Source
const (
	Unknown                  = iota
	Websocket       ConnType = iota
	LongpollingPull          = iota
	LongpollingPush          = iota
)

Variables

This section is empty.

Functions

func SendData

func SendData(ch chan Message, data Message)

Types

type Conn

type Conn interface {
	Send
	Request() *http.Request
	Cid() Uid
}

type ConnType

type ConnType int

type Decoder

type Decoder interface {
	Decode() (Message, error)
	Encode(msg Message) ([]byte, error)
}

type Engine

type Engine interface {
	Send
	http.Handler
	GetRoom(name Uid) Room
	AddRoom(name Uid) Room
	Config() EngineConfig
	// contains filtered or unexported methods
}

func NewEngine

func NewEngine(config EngineConfig) Engine

type EngineConfig

type EngineConfig interface {
	OnConnection(conn Conn) (*Uid, *Uid)
	OnSubscriberDisconnect(subscriber Subscriber)
	OnMessage(subscriber Subscriber, data Message)
	NewDecoder(reader *bufio.Reader) Decoder
	GetConnType(r *http.Request) ConnType
	GetLpDropTime(subscriber Subscriber) time.Duration
	GetLpWaitTime(subscriber Subscriber) time.Duration
}

type Message

type Message interface {
	GetRoom() string
	SetRoom(room string)
}

type Object

type Object interface {
	Send
	Uid() Uid
	Engine() Engine
}

type Room

type Room interface {
	Object
	Join(client Subscriber)
	Remove(client Subscriber)
	Subscribers() *map[Uid]Subscriber
	// contains filtered or unexported methods
}

type Send

type Send interface {
	Send(data Message)
}

type Subscriber

type Subscriber interface {
	Object
	Rooms() *[]Room
	// contains filtered or unexported methods
}

type Uid

type Uid string

Jump to

Keyboard shortcuts

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