updated controller implementation (use channels)
This commit is contained in:
parent
a3f72a9bf7
commit
db2b24ae51
|
@ -15,20 +15,26 @@ func main(){
|
||||||
serv := ws.CreateServer("0.0.0.0", 4444)
|
serv := ws.CreateServer("0.0.0.0", 4444)
|
||||||
|
|
||||||
/* (2) Bind default controller */
|
/* (2) Bind default controller */
|
||||||
err := serv.BindDefault(func(c *ws.Client, f *ws.Frame){
|
err := serv.BindDefault(func(c *ws.Client, f chan *ws.Frame){
|
||||||
fmt.Printf("Default controller\n")
|
|
||||||
if f != nil {
|
fmt.Printf("[default] connected\n")
|
||||||
fmt.Printf("Received: '%s'\n", f.Buf)
|
for frame := range f {
|
||||||
|
fmt.Printf("[default] received '%s'\n", frame.Buf)
|
||||||
}
|
}
|
||||||
|
fmt.Printf("[default] closed\n")
|
||||||
|
|
||||||
})
|
})
|
||||||
if err != nil { panic(err) }
|
if err != nil { panic(err) }
|
||||||
|
|
||||||
/* (3) Bind to URI */
|
/* (3) Bind to URI */
|
||||||
err = serv.Bind("/channel/./room/./", func(c *ws.Client, f *ws.Frame){
|
err = serv.Bind("/channel/./room/./", func(c *ws.Client, f chan *ws.Frame){
|
||||||
fmt.Printf("URI controller\n")
|
|
||||||
if f != nil {
|
fmt.Printf("[uri] connected\n")
|
||||||
fmt.Printf("Received: '%s'\n", f.Buf)
|
for frame := range f {
|
||||||
|
fmt.Printf("[uri] received '%s'\n", frame.Buf)
|
||||||
}
|
}
|
||||||
|
fmt.Printf("[uri] closed\n")
|
||||||
|
|
||||||
})
|
})
|
||||||
if err != nil { panic(err) }
|
if err != nil { panic(err) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue