chatserver

package
v0.0.0-...-d81b0cc Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginHandle

func LoginHandle(w http.ResponseWriter, r *http.Request)

LoginHandle is the handle to /login, LoginHandle checks for token cookies, and check validity If no tokens are provided, LoginHandle takes a form encoded user and password, and logs in, setting the token cookie to the users session token

func SignupHandle

func SignupHandle(w http.ResponseWriter, r *http.Request)

SignupHandle handles /signup, takes a form encoded username and password, checks the database for an existing user, and sets the session token cookie, and redirects to the chat

func WebsocketHandlerMock

func WebsocketHandlerMock(w http.ResponseWriter, r *http.Request)

WebsocketHandlerMock is handle to /websocketmock, WebsocketHandlerMock fakes a chat server, clients should use this if they wish to test their client, WebsocketHandlerMock does not check cookies and assumes the user is test

Types

type Broadcast

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

Broadcast is a pool of UserConn why would like to send and recieve broadcast

func Pool

func Pool() *Broadcast

Pool returns a ponter to the global Broadcast Pool

func (*Broadcast) Broadcast

func (b *Broadcast) Broadcast(v interface{})

Broadcast sends a struct to each UserConn in the broadcast pool

func (*Broadcast) Join

func (b *Broadcast) Join(conn *UserConn)

Join adds the UserConn to the broadcast pool, blocking until done so

func (*Broadcast) Leave

func (b *Broadcast) Leave(conn *UserConn)

Leave removes the UserConn from the broadcast pool, blocking until done so

func (*Broadcast) Pump

func (b *Broadcast) Pump()

Pump continuously polls the broacast pool and distributes messages

type PingMessage

type PingMessage struct {
	Msgtype string
	Time    string
}

todo move to own file

type UserConn

type UserConn struct {
	Username   string
	Token      string
	Connection websocket.Conn
	Send       chan interface{}
}

UserConn is a websocket connection of a chat user

func (*UserConn) Close

func (u *UserConn) Close()

Close closes the websocket from the server and and renews the Token a final time

func (*UserConn) Pump

func (u *UserConn) Pump()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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