mirror of https://github.com/matrix-org/gomatrix
Test example file
This commit is contained in:
parent
9c35a1edb8
commit
76fa23b9a4
12
client.go
12
client.go
|
@ -1,18 +1,6 @@
|
||||||
// Package gomatrix implements the Matrix Client-Server API.
|
// Package gomatrix implements the Matrix Client-Server API.
|
||||||
//
|
//
|
||||||
// Specification can be found at http://matrix.org/docs/spec/client_server/r0.2.0.html
|
// Specification can be found at http://matrix.org/docs/spec/client_server/r0.2.0.html
|
||||||
//
|
|
||||||
// Example usage of this library: (blocking version)
|
|
||||||
// cli, _ := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe")
|
|
||||||
// syncer := cli.Syncer.(*gomatrix.DefaultSyncer)
|
|
||||||
// syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) {
|
|
||||||
// fmt.Println("Message: ", ev)
|
|
||||||
// })
|
|
||||||
// if err := cli.Sync(); err != nil {
|
|
||||||
// fmt.Println("Sync() returned ", err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// To make the example non-blocking, call Sync() in a goroutine.
|
|
||||||
package gomatrix
|
package gomatrix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue