handler

package
v0.0.0-...-77682ad Latest Latest
Warning

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

Go to latest
Published: May 11, 2014 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package handler contains the TCP (Telnet) and Websocket handling as well as providing the static files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Home

func Home(rw http.ResponseWriter, req *http.Request)

Home returns the index.html.

func NotFound

func NotFound(rw http.ResponseWriter, req *http.Request)

NotFound handles 404s with an own html file.

Types

type Broadcaster

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

The Broadcaster waits for messages on a channel. It will iterate over all connected clients and sends the messages to their input channels.

func NewBroadcaster

func NewBroadcaster(message chan *model.Message) *Broadcaster

NewBroadcaster creates a Broadcaster.

func (*Broadcaster) Start

func (b *Broadcaster) Start()

Start should be used as goroutine and starts the application broadcaster.

type SocketIOWrapper

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

SocketIOWrapper wraps the client and room list as well as the broadcaster channel for the Websocket server.

func NewSocketIOWrapper

func NewSocketIOWrapper(clientList *model.ClientList, roomList *model.RoomList, broadcast chan *model.Message) *SocketIOWrapper

NewSocketIOWrapper creates a SocketIOWrapper.

func (*SocketIOWrapper) OnSocketChat

func (s *SocketIOWrapper) OnSocketChat(ns *socketio.NameSpace, input SocketInput)

OnSocketChat handles all chat commands and messages from the client. It takes care of registration and command delegation.

func (*SocketIOWrapper) OnSocketConnect

func (s *SocketIOWrapper) OnSocketConnect(ns *socketio.NameSpace)

OnSocketConnect handles connect messages sent from client.

func (*SocketIOWrapper) OnSocketDisconnect

func (s *SocketIOWrapper) OnSocketDisconnect(ns *socketio.NameSpace)

OnSocketConnect handles disconnect messages sent from client. It will take care of unexpectedly disconnected clients (e.g. tab close).

type SocketInput

type SocketInput struct {
	Command string
	Body    string
}

SocketInput represents a JSON request from the client.

type TcpServerWrapper

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

TcpServerWrapper wraps the client and room list as well as the broadcaster channel for the TCP (Telnet) server.

func NewTcpServerWrapper

func NewTcpServerWrapper(clientList *model.ClientList, roomList *model.RoomList, broadcast chan *model.Message) *TcpServerWrapper

NewTcpServerWrapper creates a TcpServerWrapper.

func (*TcpServerWrapper) Start

func (tsw *TcpServerWrapper) Start()

Start should be used as goroutine and starts the TCP (Telnet) server.

Jump to

Keyboard shortcuts

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