added simple websocket connection.

This commit is contained in:
5elenay
2021-08-20 18:47:28 +03:00
parent 8b2d3d4c9a
commit 267e3baa93
4 changed files with 43 additions and 0 deletions

22
websocket.go Normal file
View File

@@ -0,0 +1,22 @@
package revoltgo
import (
"fmt"
"github.com/sacOO7/gowebsocket"
)
const WS_URL = "wss://ws.revolt.chat"
func (c *Client) Start() {
// Create new socket
c.Socket = gowebsocket.New(WS_URL)
// Send auth when connected
c.Socket.OnConnected = func(socket gowebsocket.Socket) {
c.Socket.SendText(fmt.Sprintf("{\"type\": \"Authenticate\", \"token\": \"%s\"}", c.Token))
}
// Start connection
c.Socket.Connect()
}