From 9c35a1edb86cb25d59b658e0a8d460bc28885b66 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 9 Dec 2016 16:04:32 +0000 Subject: [PATCH] Add JoinRoom examples --- client_examples_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client_examples_test.go b/client_examples_test.go index 775e58b..8f2c361 100644 --- a/client_examples_test.go +++ b/client_examples_test.go @@ -38,6 +38,25 @@ func ExampleClient_StateEvent() { } } +// Join a room by ID. +func ExampleClient_JoinRoom_id() { + cli, _ := NewClient("http://localhost:8008", "@example:localhost", "abcdef123456") + if _, err := cli.JoinRoom("!uOILRrqxnsYgQdUzar:localhost", "", nil); err != nil { + panic(err) + } +} + +// Join a room by alias. +func ExampleClient_JoinRoom_alias() { + cli, _ := NewClient("http://localhost:8008", "@example:localhost", "abcdef123456") + if resp, err := cli.JoinRoom("#test:localhost", "", nil); err != nil { + panic(err) + } else { + // Use room ID for something. + _ = resp.RoomID + } +} + // Login to a local homeserver. This will set Client.UserID and Client.AccessToken on success. func ExampleClient_Login() { cli, _ := NewClient("http://localhost:8008", "", "")