rpcfetch/io_unix.go
Ophestra Umiker a985e2b9df
library: io: make connection private and implement Close method
Since some of the state of the connection is tracked by the Client struct and the Raw method is sufficient for any low-level interaction with the Discord RPC, users of the API should not and does not have any reason to interact with the underlying connection.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:32:51 +09:00

21 lines
313 B
Go

package rpcfetch
import (
"net"
"time"
)
func (d *Client) dial() error {
if d.dialed {
panic("attempted to dial on open client")
}
if conn, err := net.DialTimeout("unix", sockPath()+"/discord-ipc-0", 5*time.Second); err != nil {
return err
} else {
d.conn = conn
d.dialed = true
}
return nil
}