core

package
v0.0.0-...-5a9142d Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatMessagePIDString = "2.0.7.2"
	JoinRoomPIDString    = "2.0.7.3"
	LeaveRoomPIDString   = "2.0.7.4"
)
View Source
const (
	RoomBufSize = 1000
)

Variables

View Source
var (
	ChatMessagePID = bw.FromDotForm("2.0.7.2")
	JoinRoomPID    = bw.FromDotForm("2.0.7.3")
	LeaveRoomPID   = bw.FromDotForm("2.0.7.4")
)

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	// the message to send to the chatroom
	Message string
	Alias   string
}

func WrapError

func WrapError(err error) *ChatMessage

func (ChatMessage) ToBW

func (msg ChatMessage) ToBW() bw.PayloadObject

type JoinRoom

type JoinRoom struct {
	// the name you will be known by in the chatroom
	Alias string
}

func (JoinRoom) ToBW

func (msg JoinRoom) ToBW() bw.PayloadObject

type LeaveRoom

type LeaveRoom struct {
	// why you left the chatroom. Will be sent to all members in the room
	Reason string
}

func (LeaveRoom) ToBW

func (msg LeaveRoom) ToBW() bw.PayloadObject

type Message

type Message struct {
	Message string
	FromVK  string
	From    string
	Room    *Room
}

type OrdoCore

type OrdoCore struct {

	// log of actions taken
	Log chan string
	// your name
	Alias string

	// handlers
	ReceivedJoin  func(msg JoinRoom)
	ReceivedLeave func(msg LeaveRoom)
	ReceivedChat  func(msg ChatMessage)
	// contains filtered or unexported fields
}

func NewOrdoCore

func NewOrdoCore(entityfile, alias string) *OrdoCore

func (*OrdoCore) GetRooms

func (ordo *OrdoCore) GetRooms() []*Room

fills in the map with our current rooms

func (*OrdoCore) JoinRoom

func (ordo *OrdoCore) JoinRoom(roomURI string) (*Room, error)

Join the chatroom at the given URI using alias as your nickname. Needs consume privileges to listen in the room, and publish privileges to send messages to the room. Returns true if the room was created for the first time

type Room

type Room struct {

	// URI of the room
	URI string
	// name of room derived from URI
	Name string
	// your name in the room
	Alias string
	// whether or not the room can be used
	Alive bool
	// contains filtered or unexported fields
}

represents an Ordo chat room

func NewRoom

func NewRoom(roomURI string, ordo *OrdoCore, bufsize int) (*Room, error)

func (*Room) Join

func (room *Room) Join() error

join the room. Sends a JoinMessage to all subscribers and subscribes to the room

func (*Room) Leave

func (room *Room) Leave(reason string) error

func (*Room) SetStateUpdateCallback

func (room *Room) SetStateUpdateCallback(fxn func(state RoomState))

function to be invoked when the room's state changes

func (*Room) Speak

func (room *Room) Speak(msg string) error

func (*Room) StartTail

func (room *Room) StartTail(dest chan Message)

func (*Room) StopTail

func (room *Room) StopTail()

type RoomState

type RoomState struct {
	NumUnreadMessages int32
	NumCurrentUsers   int32
	Name              string
	CurrentUsers      map[string]string
	Room              *Room
}

func (RoomState) Height

func (state RoomState) Height() int

Jump to

Keyboard shortcuts

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