matrix_random_sdk

package module
v0.2.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: MIT Imports: 10 Imported by: 0

README

matrix_random_sdk

could be used as an sdk, idk.

plans

  • login (and then 0.1.0)
  • joining rooms
  • sending messages
  • creating rooms

other plans:

  • different methods of syncing
    • polling
    • long lived request?

random with self

so... i'm writing a matrix client in go and it's stupid basic and maybe i'll learn or waste my time, idk. maybe something i can do to waste time on things i don't care about.

Documentation

Overview

A library/SDK for interfacing to the homeserver as a client.

Index

Constants

View Source
const (
	DiscoveryPrompt     = "PROMPT"
	DiscoveryIgnore     = "IGNORE"
	DiscoveryFailPrompt = "FAIL_PROMPT"
	DiscoveryFailError  = "FAIL_ERROR"
)

refer spec: https://spec.matrix.org/v1.2/client-server-api/#server-discovery

View Source
const (
	SpecVersionSupport = "v1.2"
)

Variables

This section is empty.

Functions

func DiscoverHSIdentityServer

func DiscoverHSIdentityServer(server_name *url.URL) (identity_server_base_URL *url.URL, err error)

discovers the identity server for the homeserver via delegation the request for delegation information is likely not cached, so calling both DiscoverHSURL and DiscoverHSIdentityServer will call fetchDelegation in total 2 times fetching the resource twice.

func DiscoverHSURL

func DiscoverHSURL(server_name *url.URL) (homeserver_base_URL *url.URL, err error)

discovers homeserver baseurl from just the homeserver name when it does not succeed, it will return one of the Discovery* variable contents included in the error, and nil as the url. if any other error occurs, that error will be returned.

identity_server_base_URL currently only returns nil as it is not yet implemented. however, it may be planned to be implemented in the future.

refer spec: https://spec.matrix.org/v1.2/client-server-api/#getwell-knownmatrixclient

Types

type Homeserver

type Homeserver struct {
	BaseURL *url.URL
}

func (*Homeserver) GetLoginFlows

func (hs *Homeserver) GetLoginFlows() (loginTypes *loginTypes, err error)

func (Homeserver) SendRequest

func (hs Homeserver) SendRequest(method string, path string, request_body *string) (*http.Response, error)

low level method: sends a request to the homeserver and returns the response

it is recommended to use net/url.Method* constants for the method `parameter`. if request_body parameter is `nil`, an empty request body will be sent.

returns error from net/http if error occurs from that TODO: creates error if HS responds with standard error response spec refer: https://spec.matrix.org/v1.2/client-server-api/#standard-error-response

func (Homeserver) Supported

func (hs Homeserver) Supported() (bool, error)

checks if a homeserver has implemented the exact version the specification returns error if there's anything wrong (like http request failure or json failure) spec refer: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientversions

type IdentityServer

type IdentityServer struct {
	BaseURL *url.URL
}

type ServerName

type ServerName struct {
	Hostname string // TODO needs validation
	Port     int
}

func (ServerName) String

func (s ServerName) String() string

converts the server name to a string

type UserID

type UserID struct {
	Localpart  string // TODO needs validation
	ServerName ServerName
}

func (UserID) String

func (uid UserID) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL