mirror of https://github.com/matrix-org/gomatrix
Simplify example
This commit is contained in:
parent
b8025f5f6d
commit
47da1cbcf2
|
@ -4,23 +4,19 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
func Example_blockingSync() {
|
||||
func Example_sync() {
|
||||
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)
|
||||
})
|
||||
|
||||
// Blocking version
|
||||
if err := cli.Sync(); err != nil {
|
||||
fmt.Println("Sync() returned ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Example_nonBlockingSync() {
|
||||
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)
|
||||
})
|
||||
// Non-blocking version
|
||||
go func() {
|
||||
for {
|
||||
if err := cli.Sync(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue