parser

package
v0.0.0-...-912cea7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckMsg

type AckMsg struct {
	Username string
	Message  string
	Type     AckMsgType
}

AckMsg represents the message sent back by ssh-chat

type AckMsgType

type AckMsgType int

AckMsgType represents what kind of message was acknowledged

const (
	// AckMsgPublic means public message was acknowledged
	AckMsgPublic AckMsgType = iota
	// AckMsgPrivate means private message was acknowledged
	AckMsgPrivate
)

type ActionMsg

type ActionMsg struct {
	From    string
	Message string
}

ActionMsg represents a public message sent as an action '/me <something>'

type JoinMsg

type JoinMsg struct {
	Username string
	Status   UserConnStatus
}

JoinMsg represents message published by server about people joining or leaving

type Parser

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

Parser is used to understand lines sent by ssh-chat

func New

func New() *Parser

New creates a new parser

func (*Parser) Parse

func (p *Parser) Parse(line []byte) (RoomMsg, error)

Parse published line

type PrivateMsg

type PrivateMsg struct {
	From    string
	Message string
}

PrivateMsg represents message sent to the user directly

type PublicMsg

type PublicMsg struct {
	From    string
	Message string
}

PublicMsg represents message sent to the room

type RoomMsg

type RoomMsg interface{}

RoomMsg is one of {UsernameChangeMsg, JoinMsg, PrivateMsg, PublicMsg, ActionMsg}

type SystemMsg

type SystemMsg struct {
	Message string
}

SystemMsg represents the system messages ssh-chat sends periodically

type UserConnStatus

type UserConnStatus int

UserConnStatus represents user's connected status

const (
	// UserJoined means the user connected to the server
	UserJoined UserConnStatus = iota
	// UserLeft means the user disconnected from the server
	UserLeft
)

func (UserConnStatus) String

func (u UserConnStatus) String() string

type UsernameChangeMsg

type UsernameChangeMsg struct {
	FromUsername string
	ToUsername   string
}

UsernameChangeMsg represents message published by server about users changing their names

Jump to

Keyboard shortcuts

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