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)
|
||||
|
||||
/* (2) Bind default controller */
|
||||
err := serv.BindDefault(func(c *ws.Client, f *ws.Frame){
|
||||
fmt.Printf("Default controller\n")
|
||||
if f != nil {
|
||||
fmt.Printf("Received: '%s'\n", f.Buf)
|
||||
err := serv.BindDefault(func(c *ws.Client, f chan *ws.Frame){
|
||||
|
||||
fmt.Printf("[default] connected\n")
|
||||
for frame := range f {
|
||||
fmt.Printf("[default] received '%s'\n", frame.Buf)
|
||||
}
|
||||
fmt.Printf("[default] closed\n")
|
||||
|
||||
})
|
||||
if err != nil { panic(err) }
|
||||
|
||||
/* (3) Bind to URI */
|
||||
err = serv.Bind("/channel/./room/./", func(c *ws.Client, f *ws.Frame){
|
||||
fmt.Printf("URI controller\n")
|
||||
if f != nil {
|
||||
fmt.Printf("Received: '%s'\n", f.Buf)
|
||||
err = serv.Bind("/channel/./room/./", func(c *ws.Client, f chan *ws.Frame){
|
||||
|
||||
fmt.Printf("[uri] connected\n")
|
||||
for frame := range f {
|
||||
fmt.Printf("[uri] received '%s'\n", frame.Buf)
|
||||
}
|
||||
fmt.Printf("[uri] closed\n")
|
||||
|
||||
})
|
||||
if err != nil { panic(err) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue