mirror of https://github.com/matrix-org/gomatrix
Add example usage
This commit is contained in:
parent
ca6f598808
commit
519d03ed04
15
client.go
15
client.go
|
@ -1,6 +1,20 @@
|
||||||
// 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, err := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")
|
||||||
|
// if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
// }
|
||||||
|
// cli.Syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) {
|
||||||
|
// fmt.Println("Message: %+v", ev)
|
||||||
|
// })
|
||||||
|
// if err := cli.Sync(); err != nil {
|
||||||
|
// panic(err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// To make the example non-blocking, call Sync() in a goroutine.
|
||||||
package gomatrix
|
package gomatrix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -26,7 +40,6 @@ type Client struct {
|
||||||
syncingID uint32 // Identifies the current Sync. Only one Sync can be active at any given time.
|
syncingID uint32 // Identifies the current Sync. Only one Sync can be active at any given time.
|
||||||
Client *http.Client // The underlying HTTP client which will be used to make HTTP requests.
|
Client *http.Client // The underlying HTTP client which will be used to make HTTP requests.
|
||||||
Syncer Syncer // The thing which can process /sync responses
|
Syncer Syncer // The thing which can process /sync responses
|
||||||
// TODO: Worker and Rooms
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPError An HTTP Error response, which may wrap an underlying native Go Error.
|
// HTTPError An HTTP Error response, which may wrap an underlying native Go Error.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package gomatrix
|
package gomatrix
|
||||||
|
|
||||||
import (
|
import "fmt"
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ExampleClient_BuildURLWithQuery() {
|
func ExampleClient_BuildURLWithQuery() {
|
||||||
cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")
|
cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")
|
||||||
|
|
Loading…
Reference in New Issue