room

package
v0.0.0-...-4f83aec Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2016 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERR_MAX_ROOMS = errors.New("Can't create room.  There are already the maximum number of rooms.")
View Source
var ERR_ROOM_EXISTS = errors.New("A room with that name already exits.")

Functions

func NewClientList

func NewClientList() *clientList

NewClientList returns a pointer to an empty clientList.

Types

type Client

type Client interface {
	Equals(other Client) bool
	Name() string
	Recieve(m message.Message)
}

Client interface for working with the Room type.

type Room

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

Room is a room name and a linked list of clients in the room.

func NewRoom

func NewRoom(name string) *Room

NewRoom creates a room with name.

func (*Room) Add

func (rm *Room) Add(cl Client)

Add adds a client to a room.

func (*Room) Equals

func (rm *Room) Equals(other Client) bool

Equals returns true if the rooms have the same name.

func (*Room) GetClient

func (rm *Room) GetClient(name string) Client

GetClient returns the first client with name from the room.

func (Room) GetMessages

func (rm Room) GetMessages() []string

GetMessages gets the messages from the room message list and returns them as a []string.

func (*Room) IsEmpty

func (rm *Room) IsEmpty() bool

IsEmpty returns true if the room is empty.

func (*Room) Name

func (rm *Room) Name() string

Name returns the name of the room.

func (Room) NumberOfClients

func (rm Room) NumberOfClients() int

func (*Room) Present

func (rm *Room) Present(name string) bool

func (*Room) Recieve

func (rm *Room) Recieve(m message.Message)

Recieve passes messages the room recieves to all clients in the room's client list.

func (*Room) Remove

func (rm *Room) Remove(cl Client) bool

Remove removes a client from the room.

func (*Room) Send

func (rm *Room) Send(m message.Message)

Send puts the message into each client in the room's recieve function.

func (Room) Tell

func (rm Room) Tell(s string)

Tell sends a string to the room from the server.

func (*Room) Who

func (rm *Room) Who() []string

Who returns a slice of the names of all the clients in the rooms client list.

type RoomList

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

RoomList is a linked list of rooms with a mutex.

func NewRoomList

func NewRoomList(maxRooms int) *RoomList

NewRoomList returns an empty RoomList.

func (*RoomList) Add

func (rml *RoomList) Add(cl Client) error

func (*RoomList) Close

func (rml *RoomList) Close()

func (*RoomList) CloseEmpty

func (rml *RoomList) CloseEmpty()

CloseEmpty closes all empty rooms.

func (*RoomList) FindClientRoom

func (rml *RoomList) FindClientRoom(name string) string

FindClientRoom returns the name of a room that a client with name is in.

func (*RoomList) FindRoom

func (rml *RoomList) FindRoom(name string) *Room

FindRoom returns the first room with name.

func (*RoomList) GetClient

func (rml *RoomList) GetClient(name string) Client

GetClient returns the first client that matches name.

func (RoomList) Present

func (c RoomList) Present(name string) bool

Present returns true if a client with matching name is in the clientlist.

func (RoomList) Rem

func (c RoomList) Rem(cl Client) bool

Rem removes all clients from the list that are equal to c.

func (RoomList) Who

func (c RoomList) Who() []string

Who returns a []string with all the names of the clients in the list sorted.

Jump to

Keyboard shortcuts

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