vendor/github.com/hugolgst/rich-go/ipc/ipc_windows.go
22 lines · 502 bytes
1// +build windows
2
3package ipc
4
5import (
6 npipe "gopkg.in/natefinch/npipe.v2"
7 "time"
8)
9
10// OpenSocket opens the discord-ipc-0 named pipe
11func OpenSocket() error {
12 // Connect to the Windows named pipe, this is a well known name
13 // We use DialTimeout since it will block forever (or very very long) on Windows
14 // if the pipe is not available (Discord not running)
15 sock, err := npipe.DialTimeout(`\\.\pipe\discord-ipc-0`, time.Second*2)
16 if err != nil {
17 return err
18 }
19
20 socket = sock
21 return nil
22}