gomatrix/example_test.go

18 lines
416 B
Go

package gomatrix
import (
"fmt"
)
func Example() {
cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe")
syncer := cli.Syncer.(*DefaultSyncer)
syncer.OnEventType("m.room.message", func(ev *Event) {
fmt.Println("Message: ", ev)
})
// To make the example non-blocking, call Sync() in a goroutine.
if err := cli.Sync(); err != nil {
fmt.Println("Sync() returned ", err)
}
}