From 519d03ed04450d2d8cdef7e96bbba0b1a300d165 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 30 Nov 2016 17:41:14 +0000 Subject: [PATCH] Add example usage --- client.go | 15 ++++++++++++++- client_test.go | 4 +--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index db0eccf..dc82357 100644 --- a/client.go +++ b/client.go @@ -1,6 +1,20 @@ // Package gomatrix implements the Matrix Client-Server API. // // 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 import ( @@ -26,7 +40,6 @@ type Client struct { 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. 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. diff --git a/client_test.go b/client_test.go index e3fce2c..6a12a9a 100644 --- a/client_test.go +++ b/client_test.go @@ -1,8 +1,6 @@ package gomatrix -import ( - "fmt" -) +import "fmt" func ExampleClient_BuildURLWithQuery() { cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "abcdef123456")