pad

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangesetClient

type ChangesetClient struct {
	Changsetserverpath string

	Downloadeurl string
	// contains filtered or unexported fields
}

func NewChangesetClient

func NewChangesetClient(ip string, port string) *ChangesetClient

func (*ChangesetClient) Close

func (cc *ChangesetClient) Close()

func (*ChangesetClient) Connect

func (cc *ChangesetClient) Connect() error

func (*ChangesetClient) GenerateChangeset

func (cc *ChangesetClient) GenerateChangeset(oldtext string, newtext string, attribs string) (string, error)

func (*ChangesetClient) StartChangesetServer

func (cc *ChangesetClient) StartChangesetServer() error

func (*ChangesetClient) StopChangesetServer

func (cc *ChangesetClient) StopChangesetServer()

type Pad

type Pad struct {
	URL          string //"https://example.com/pad/"
	WsURL        string //"wss://example.com/pad/"
	SessionToken string
	PadId        string
	SessionID    string
	Cookie       []*http.Cookie

	ChangesetServerIP   string
	ChangesetServerPort string

	Client *goSocketio.Client

	AuthorID string
	Text     string
	Attribs  string

	BaseRev   int
	LocationX int

	ChangesetServerExternal bool
	ChangesetClient         *ChangesetClient
}

func NewPad

func NewPad(url string, wsURL string, sessionToken string, padId string, sessionID string, cookie []*http.Cookie, external bool, host string, port int) *Pad

Create new pad wsURL = "wss://example.com/pad/" SessionToken = gtxiomrffih2b8qr (from bbb) padId = g.9d4O2LRqTkIfh6bM$notes (from ddp. To get it c.ddpCall(bbb.GetPadIdCall, "en")) sessionID = s.4918c0b0b9b7913b5e29334a50f58212 (from ddp. To get it padsSessionsCollection.FindAll()) cookie = client.SessionCookie

func (*Pad) Connect

func (p *Pad) Connect() error

Connect to the pad

func (*Pad) Disconnect

func (p *Pad) Disconnect()

Disconnect from the pad

func (*Pad) RegisterSession

func (p *Pad) RegisterSession() error

Register session

func (*Pad) SetText

func (p *Pad) SetText(text string) error

type ReceveClientReady

type ReceveClientReady struct {
	Data struct {
		UserID           string `json:"userId"`
		CollabClientVars struct {
			InitialAttributedText struct {
				Text    string `json:"text"`
				Attribs string `json:"attribs"`
			} `json:"initialAttributedText"`
			Rev int `json:"rev"`
		} `json:"collab_client_vars"`
	} `json:"data"`
}

Initial response from the server

type ReceveConfirmSendChar

type ReceveConfirmSendChar struct {
	Type string `json:"type"`
	Data struct {
		Type   string `json:"type"`
		NewRev int    `json:"newRev"`
	} `json:"data"`
}

Server will confim the SendChar sent by this client {"type":"COLLABROOM","data":{"type":"ACCEPT_COMMIT","newRev":1}}

type ReceveCursorPosition

type ReceveCursorPosition struct {
	Type string `json:"type"`
	Data struct {
		Type    string `json:"type"`
		Payload struct {
			Action     string `json:"action"`
			AuthorID   string `json:"authorId"`
			AuthorName string `json:"authorName"`
			PadID      string `json:"padId"`
			LocationX  int    `json:"locationX"`
			LocationY  int    `json:"locationY"`
		} `json:"payload"`
	} `json:"data"`
}

Server will send a cursor position, if a outher user moved the cursor {"type":"COLLABROOM","data":{"type":"CUSTOM","payload":{"action":"cursorPosition","authorId":"a.3JMUunbWzLnaV1Ox","authorName":"Julian","padId":"g.VPluJJUveQlgElgN$notes","locationX":0,"locationY":0}}}

type ReceveData

type ReceveData struct {
	Type string `json:"type"`
	Data struct {
		Type string `json:"type"`
	} `json:"data"`
}

Server will send data which has a Type. To get the type use ReceveData.Data.Type {"type":"COLLABROOM","data":{"type":"ACCEPT_COMMIT",...}}

type ReceveNewUser

type ReceveNewUser struct {
	Type string `json:"type"`
	Data struct {
		Type     string `json:"type"`
		UserInfo struct {
			ColorID int    `json:"colorId"`
			Name    string `json:"name"`
			UserID  string `json:"userId"`
		} `json:"userInfo"`
	} `json:"data"`
}

Server will send a new user, if a outher user joined the pad {"type":"COLLABROOM","data":{"type":"USER_NEWINFO","userInfo":{"colorId":9,"name":"Julian","userId":"a.MO7GXKUWttjc4se8"}}}

type ReceveSendChar

type ReceveSendChar struct {
	Type string `json:"type"`
	Data struct {
		Type      string `json:"type"`
		NewRev    int    `json:"newRev"`
		Changeset string `json:"changeset"`
		Apool     struct {
			NumToAttrib struct {
				Num0 []string `json:"0"`
			} `json:"numToAttrib"`
			AttribToNum interface{} `json:"attribToNum"`
			NextNum     int         `json:"nextNum"`
		} `json:"apool"`
		Author      string `json:"author"`
		CurrentTime int64  `json:"currentTime"`
		TimeDelta   any    `json:"timeDelta"`
	} `json:"data"`
}

Server will send char, if a outher user wrote a char {"type":"COLLABROOM","data":{"type":"NEW_CHANGES","newRev":3,"changeset":"Z:3>1=2*0+1$b","apool":{"numToAttrib":{"0":["author","a.MO7GXKUWttjc4se8"]},"attribToNum":{"author,a.MO7GXKUWttjc4se8":0},"nextNum":1},"author":"a.MO7GXKUWttjc4se8","currentTime":1677492927116,"timeDelta":null}}

type SendChar

type SendChar struct {
	Type      string `json:"type"`
	Component string `json:"component"`
	Data      struct {
		Type      string `json:"type"`
		BaseRev   int    `json:"baseRev"`
		Changeset string `json:"changeset"`
		Apool     struct {
			NumToAttrib struct {
				Num0 []string `json:"0"`
			} `json:"numToAttrib"`
			NextNum int `json:"nextNum"`
		} `json:"apool"`
	} `json:"data"`
}

Send this to the Server to send a char {"type":"COLLABROOM","component":"pad","data":{"type":"USER_CHANGES","baseRev":0,"changeset":"Z:1>1*0+1$h","apool":{"numToAttrib":{"0":["author","a.3JMUunbWzLnaV1Ox"]},"nextNum":1}}}

type SendCursorPosition

type SendCursorPosition struct {
	Type      string `json:"type"`
	Component string `json:"component"`
	Data      struct {
		Type       string `json:"type"`
		Action     string `json:"action"`
		LocationY  int    `json:"locationY"`
		LocationX  int    `json:"locationX"`
		PadID      string `json:"padId"`
		MyAuthorID string `json:"myAuthorId"`
	} `json:"data"`
}

Send this to the Server to send a cursor position {"type":"COLLABROOM","component":"pad","data":{"type":"cursor","action":"cursorPosition","locationY":0,"locationX":1,"padId":"g.VPluJJUveQlgElgN$notes","myAuthorId":"a.3JMUunbWzLnaV1Ox"}}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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