punchy

package
v0.0.0-...-bfce645 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const MAX_UDP_DATAGRAM = 65507

Variables

View Source
var ProtocolReadError = errors.New("Message cannot be read")
View Source
var ProtocolWriteError = errors.New("Message cannot be written")

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	RoomMessage
	Message string
}

func (*ChatMessage) DecodeMessage

func (m *ChatMessage) DecodeMessage(buf []byte) error

func (*ChatMessage) EncodeMessage

func (m *ChatMessage) EncodeMessage() ([]byte, error)

type ChatRoom

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

type ChatServer

type ChatServer interface {
	Serve()
	Encrypted() bool
	AddUserToRoom(string *net.UDPAddr)
}

type Client

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

func NewClient

func NewClient(hostname string, port *int) *Client

func (*Client) ClientContiniousRead

func (c *Client) ClientContiniousRead()

func (*Client) ClientContiniousWrite

func (c *Client) ClientContiniousWrite(messageChan chan string, roomName string)

func (*Client) ConnectToMiddleMan

func (c *Client) ConnectToMiddleMan()

func (*Client) ConnectToRoom

func (c *Client) ConnectToRoom(inputStream chan string, roomName string)

func (*Client) Display

func (c *Client) Display(displayChan chan string)

func (*Client) MakeRoomMessage

func (c *Client) MakeRoomMessage(roomName, message string) Message

func (*Client) Pong

func (c *Client) Pong()

func (*Client) StartUp

func (c *Client) StartUp(displayChan chan string)

func (*Client) UpdateRoomList

func (c *Client) UpdateRoomList(message Message)

type ClientInter

type ClientInter interface {
	ConnectToRoom(io.Reader, string)
	ConnectToServer(*net.UDPAddr)
}

type ConnectRoomMessage

type ConnectRoomMessage struct {
	RoomMessage
	// contains filtered or unexported fields
}

func (*ConnectRoomMessage) DecodeMessage

func (m *ConnectRoomMessage) DecodeMessage(buf []byte) error

func (*ConnectRoomMessage) EncodeMessage

func (m *ConnectRoomMessage) EncodeMessage() ([]byte, error)

type InboundMessage

type InboundMessage interface {
	Sender() *net.UDPAddr
	DataAsString() string
	RawData() []byte
	Size() int
	Encrypted() bool
	Type() MessageType
	DecodeMessage(*net.UDPAddr, []byte) error
}

type Message

type Message struct {
	RawMessage
	MsgType      MessageType
	EncryptedMsg bool
	Length       uint16
}

func (*Message) DataAsString

func (m *Message) DataAsString() string

func (*Message) DecodeMessage

func (m *Message) DecodeMessage(sender *net.UDPAddr, p []byte) error

func (*Message) EncodeMessage

func (m *Message) EncodeMessage() ([]byte, error)

func (*Message) Encrypted

func (m *Message) Encrypted() bool

func (*Message) RawData

func (m *Message) RawData() []byte

func (*Message) Sender

func (m *Message) Sender() *net.UDPAddr

func (*Message) Size

func (m *Message) Size() int

func (*Message) Type

func (m *Message) Type() MessageType

type MessageType

type MessageType uint8
const (
	PING                  MessageType = 1
	PONG                  MessageType = 2
	CONNECT_TO_MIDDLE_MAN MessageType = 3
	RESPOND_TO_MIDDLE_MAN MessageType = 4
	CONNECT_TO_ROOM       MessageType = 5
	DISCONNECT_FROM_ROOM  MessageType = 6
	ROOM_LIST             MessageType = 7
	ROOM_MESSAGE          MessageType = 8
	ROOM_HISTORY          MessageType = 9
)

type OutboundMessage

type OutboundMessage interface {
	RawMessage() RawMessage
}

type Peer

type Peer struct {
	net.UDPAddr
	// contains filtered or unexported fields
}

type RawMessage

type RawMessage struct {
	Sender *net.UDPAddr
	Data   []byte
}

type RemoteClient

type RemoteClient struct {
	Uptime
	// contains filtered or unexported fields
}

type RoomListMessage

type RoomListMessage struct {
	RoomMessage
	Length    uint16
	Addresses []net.UDPAddr
}

func (*RoomListMessage) DecodeMessage

func (m *RoomListMessage) DecodeMessage(buf []byte) error

func (*RoomListMessage) EncodeMessage

func (m *RoomListMessage) EncodeMessage() ([]byte, error)

func (*RoomListMessage) RawMessage

func (m *RoomListMessage) RawMessage() (RawMessage, error)

type RoomMessage

type RoomMessage struct {
	Room string
}

func (*RoomMessage) DecodeMessage

func (m *RoomMessage) DecodeMessage(buf []byte) error

func (*RoomMessage) EncodeMessage

func (m *RoomMessage) EncodeMessage() ([]byte, error)

func (*RoomMessage) RawMessage

func (m *RoomMessage) RawMessage() (RawMessage, error)

type Server

type Server struct {
	Port  int
	Conn  *net.UDPConn
	Rooms map[string]*ChatRoom
}

func NewServer

func NewServer(port *int) Server

func (*Server) AddToRoom

func (s *Server) AddToRoom(roomName string, room *ChatRoom, client *RemoteClient)

func (*Server) ClientConnectToRoom

func (s *Server) ClientConnectToRoom(message Message)

func (*Server) Ping

func (s *Server) Ping(client *net.UDPAddr)

func (*Server) RoomWatcher

func (s *Server) RoomWatcher(room *ChatRoom)

func (*Server) Serve

func (s *Server) Serve()

func (*Server) UpdateRoomList

func (s *Server) UpdateRoomList(roomName string, room *ChatRoom, client *net.UDPAddr)

type Uptime

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

Jump to

Keyboard shortcuts

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