state

package
v0.0.0-...-0ace8a3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2017 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package state provides support for modeling the state of objects affected by IRC messages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllChannelStates

type AllChannelStates interface {
	State
	GetChannel(channelName string) *ChannelState
	HaveChannel(channelName string) bool
	DeleteChannel(channelName string)
}

An AllChannelStates tracks the state of all channels we're in.

type ChannelState

type ChannelState struct {
	Topic string // the topic for the channel, if any.
	// contains filtered or unexported fields
}

A ChannelState tracks state for a single channel.

func NewChannelState

func NewChannelState(topic string) *ChannelState

NewChannelState creates a new ChannelState with initial topic `topic` and no users present.

func (*ChannelState) AddUser

func (s *ChannelState) AddUser(nick string)

func (*ChannelState) HaveUser

func (s *ChannelState) HaveUser(nick string) bool

func (*ChannelState) RemoveUser

func (s *ChannelState) RemoveUser(nick string)

func (*ChannelState) UpdateFromClient

func (s *ChannelState) UpdateFromClient(msg *irc.Message)

func (*ChannelState) UpdateFromServer

func (s *ChannelState) UpdateFromServer(msg *irc.Message)

func (*ChannelState) Users

func (s *ChannelState) Users() []string

Return a slice of nicks for users in the channel

type Handshake

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

State of the initial handshake. The handshake consist of

1. Client sends NICK and USER messages 2. Server does not reject the NICK (if so, client needs to resend) 3. Server sends welcome sequence up through the MOTD.

func (Handshake) Done

func (h Handshake) Done() bool

Return true if the handshake is complete, false otherwise.

func (*Handshake) UpdateFromClient

func (h *Handshake) UpdateFromClient(msg *irc.Message)

func (*Handshake) UpdateFromServer

func (h *Handshake) UpdateFromServer(msg *irc.Message)

func (Handshake) WantsWelcome

func (h Handshake) WantsWelcome() bool

Return true if the handshake is complete on the client side, but still waiting for (some of) the server's welcome sequence.

type Session

type Session struct {
	irc.ClientID

	Handshake
	// contains filtered or unexported fields
}

Information about the state of the connection. Note that we store one of these independently for both client and server; their views may not always align.

func NewSession

func NewSession() *Session

Return a newly initialized session

func (*Session) GetChannel

func (s *Session) GetChannel(channelName string) *ChannelState

Get the state for channel `channelName`. If we're not already marked as in the channel, this adds the channel to our list and returns a fresh state.

func (*Session) HaveChannel

func (s *Session) HaveChannel(channelName string) bool

Return true if we're in the channel `channelName`, false otherwise.

func (*Session) IsMe

func (s *Session) IsMe(prefix string) bool

Return true if the prefix identifies the user associated with this session, false otherwise.

func (*Session) UpdateFromClient

func (s *Session) UpdateFromClient(msg *irc.Message)

func (*Session) UpdateFromServer

func (s *Session) UpdateFromServer(msg *irc.Message)

type State

type State interface {
	// Update the state when the client sends `msg`.
	UpdateFromClient(msg *irc.Message)

	// Update the state when the server sends `msg`.
	UpdateFromServer(msg *irc.Message)
}

Jump to

Keyboard shortcuts

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