mpp-client-go/client.go

185 lines
2.6 KiB
Go

package mppclient
import (
"log"
"net/url"
"github.com/Hri7566/mpp-client-go/mpp"
"github.com/gorilla/websocket"
)
type Client struct {
Ws *websocket.Conn
Uri string
Token string
ServerTimeOffset int
User mpp.User
ParticipantId string
Channel mpp.Channel
Ppl map[string]mpp.Participant
ConnectionTime int
ConnectionAttempts int
DesiredChannelid string
DesiredChannelSettings mpp.ChannelSettings
CanConnect bool
NoteBuffer []mpp.Note
NoteBufferTime int
Permissions any
LoginInfo mpp.LoginInfo
AccountInfo mpp.AccountInfo
}
func NewClient(uri string, token string) *Client {
url := url.URL{Scheme: "wss", Host: *addr}
ws, _, err := websocket.DefaultDialer.Dial(url.String(), nil)
if err != nil {
log.Fatal("dial:", err)
}
defer ws.Close()
return &Client{
Uri: uri,
Token: token,
Channel: mpp.Channel{
Crown: mpp.Crown{},
},
Ppl: map[string]mpp.Participant{},
ConnectionAttempts: 0,
CanConnect: false,
NoteBuffer: []mpp.Note{},
NoteBufferTime: 0,
LoginInfo: mpp.LoginInfo{},
AccountInfo: mpp.AccountInfo{},
}
}
func (c *Client) IsSupported() bool {
return true
}
func (c *Client) IsConnected() bool {
// TODO
return true
}
func (c *Client) IsConnecting() bool {
// TODO
return true
}
func (c *Client) Start() {
// TODO
}
func (c *Client) Stop() {
}
func (c *Client) connect() {
// TODO
}
func (c *Client) bindEventListners() {
// TODO
}
func (c *Client) Send(raw string) {
// TODO
}
func (c *Client) SendArray(arr any) {
// TODO
}
func (c *Client) SetChannel(id string, set any) {
// TODO
}
func (c *Client) GetChannelSetting(key string) {
// TODO
}
func (c *Client) SetChannelSettings(settings mpp.ChannelSettings) {
// TODO
}
func (c *Client) GetOwnParticipant() {
// TODO
}
func (c *Client) SetParticipants(ppl []mpp.Participant) {
}
func (c *Client) countParticipants() {
// TODO
}
func (c *Client) participantUpdate(update mpp.Participant) {
// TODO
}
func (c *Client) participantMoveMouse(update any) {
// TODO
}
func (c *Client) removeParticipant(id string) {
// TODO
}
func (c *Client) findParticipantById(id string) {
// TODO
}
func (c *Client) IsOwner() {
// TODO
}
func (c *Client) PreventsPlaying() {
// TODO
}
func (c *Client) receiveServerTime(time int, echo int) {
// TODO
}
func (c *Client) StartNote(note string, vel int) {
// TODO
}
func (c *Client) StopNote(note string) {
// TODO
}
func (c *Client) SendPing() {
// TODO
}
func (c *Client) setLoginInfo(loginInfo mpp.LoginInfo) {
// TODO
}
func (c *Client) On(event string, listener func()) {
// TODO
}
func (c *Client) Emit(event string, args ...any) {
// TODO
}