first working commit
This commit is contained in:
commit
68525224d5
9 changed files with 633 additions and 0 deletions
32
event.go
Normal file
32
event.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
type IncomingEvent interface {
|
||||
HandleIncoming(*App)
|
||||
}
|
||||
type OutgoingEvent interface {
|
||||
HandleOutgoing(*App)
|
||||
}
|
||||
|
||||
type Message string
|
||||
|
||||
func (m Message) HandleIncoming(app *App) {
|
||||
app.AppendMessage(string(m))
|
||||
}
|
||||
func (m Message) HandleOutgoing(app *App) {
|
||||
num, _ := app.Send(string(m))
|
||||
app.incoming <- SetLast(num)
|
||||
|
||||
}
|
||||
|
||||
type Poll int
|
||||
|
||||
func (p Poll) HandleOutgoing(app *App) {
|
||||
num, _ := app.Poll(int(p))
|
||||
go app.Last(num)
|
||||
}
|
||||
|
||||
type SetLast int
|
||||
|
||||
func (m SetLast) HandleIncoming(app *App) {
|
||||
app.last = int(m)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue