dispolib

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "http://www.disposablechat.com/chat"

Disposable Chat Endpoint

Variables

This section is empty.

Functions

func GetEndpoint

func GetEndpoint(room Room, path string) string

Construct a URL for a chat room

func GetTypingParam

func GetTypingParam(isTyping bool) string

Types

type Event

type Event struct {
	User    user
	Payload string
	System  bool
}

type Room

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

type Session

type Session struct {
	Name   string
	Room   Room
	Client http.Client
	// contains filtered or unexported fields
}

func New

func New(name string) (*Session, error)

Create a new session with the given username

func (*Session) AddHandler

func (s *Session) AddHandler(eventType string, h func(Event))

AddHandler adds a handler for the given event type

func (*Session) GetMessages

func (s *Session) GetMessages() error

GetMessages retrieves the current state of the chat room and runs any registered message handlers.

func (*Session) GetUserByName

func (s *Session) GetUserByName(name string) user

func (*Session) GetUsers

func (s *Session) GetUsers() []user

func (*Session) IsJoined

func (s *Session) IsJoined() bool

IsJoined checks if the session is joined to a room.

func (*Session) JoinRoom

func (s *Session) JoinRoom(room Room) error

JoinRoom attempts to join a chat room with the given room details.

func (*Session) Listen

func (s *Session) Listen()

func (*Session) ParseSystemMessage

func (s *Session) ParseSystemMessage(msg string)

func (*Session) RoomState

func (s *Session) RoomState() (roomState, error)

RoomState retrieves the current state of the chat room.

func (*Session) SendMessage

func (s *Session) SendMessage(msg string) error

SendMessage sends a message to the current chat room.

func (*Session) SetTyping

func (s *Session) SetTyping(isTyping bool) error

func (*Session) UpdateIndex

func (s *Session) UpdateIndex() error

UpdateIndex updates the room index to the latest state.

func (*Session) UpdateName

func (s *Session) UpdateName(name string) error

func (*Session) UpdateUsers

func (s *Session) UpdateUsers(users []user, runHandlers bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳