util

package
v0.0.0-...-c7d817c Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const KeyDownTime = 100

Variables

View Source
var KeyBoardChanDown = make(chan string)
View Source
var KeyBoardChanUp = make(chan string)

Functions

func AssignSocketConn

func AssignSocketConn(co *websocket.Conn)

AssignSocketConn assigns the connection pointer

func BytesToDecoder

func BytesToDecoder(b []byte) *json.Decoder

func KeyDown

func KeyDown(in string)

KeyDown presses a key down

func KeyUp

func KeyUp(in string)

KeyUp lifts a key

func PressKey

func PressKey(key string, ms int64)

PressKey press a key for ms milliseconds

func PressLeft

func PressLeft()

PressLeft turns the tank left

func PressNumber1

func PressNumber1()

PressNumber1 presses a power

func PressRight

func PressRight()

PressRight turns the tank left

func SendMessage

func SendMessage(item interface{})

SendMessage adds a message to the channel

func StartKeyboard

func StartKeyboard()

StartKeyboard ensures the server is aware of key presses

func StartSender

func StartSender()

StartSender starts a goroutine to send messages

Types

type KeyDownMessage

type KeyDownMessage struct {
	Conversation string `json:"conversation" bson:"conversation"`
	Key          string `json:"key" bson:"key"`
}

KeyDownMessage describes a message to the server

func BuildKeyDownMessage

func BuildKeyDownMessage(key string) KeyDownMessage

BuildKeyDownMessage builds a message object

type KeyUpMessage

type KeyUpMessage struct {
	Conversation string `json:"conversation" bson:"conversation"`
	Key          string `json:"key" bson:"key"`
}

KeyUpMessage describes a message to the server

func BuildKeyUpMessage

func BuildKeyUpMessage(key string) KeyUpMessage

BuildKeyUpMessage builds a message object

Jump to

Keyboard shortcuts

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