Add working example

This commit is contained in:
Kegan Dougal 2016-11-30 17:51:03 +00:00
parent 519d03ed04
commit 5391ef3078
1 changed files with 8 additions and 10 deletions

View File

@ -3,16 +3,14 @@
// 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) // Example usage of this library: (blocking version)
// cli, err := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456") // cli, _ := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe")
// if err != nil { // syncer := cli.Syncer.(*gomatrix.DefaultSyncer)
// panic(err) // syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) {
// } // fmt.Println("Message: ", ev)
// cli.Syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) { // })
// fmt.Println("Message: %+v", ev) // if err := cli.Sync(); err != nil {
// }) // fmt.Println("Sync() returned ", err)
// if err := cli.Sync(); err != nil { // }
// panic(err)
// }
// //
// To make the example non-blocking, call Sync() in a goroutine. // To make the example non-blocking, call Sync() in a goroutine.
package gomatrix package gomatrix