Commit Graph

6 Commits

Author SHA1 Message Date
Ophestra Umiker 5bb6f9f1a8
library: io: move ErrAgain to shared and errPipe value to platform-specific
ErrAgain is not platform specific however EPIPE equivalent is different on Windows.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:56:15 +09:00
Ophestra Umiker b3938173ae
library: io: expose ID, User and Config via methods
These fields can be copied safely and is useful information outside the library, so they are exposed via methods that copy their value.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-29 17:48:32 +09:00
Ophestra Umiker b3325f56b1
library: io: handle retryable errors
Discord client being absent/disconnecting is not fatal to the RPC sender, in cases like that we return ErrAgain and in the case of broken pipe (Discord client going away) also reset the Client state so the caller can choose to retry the operation and therefore initiate a new connection attempt.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-20 01:14:04 +09:00
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
Ophestra Umiker 7074a1a950
library: rpc: many RPC data types and client handshake activation
Add a few internal validation functions to make validation cleaner, activation function is called as needed so explicit client activation is not required.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:16:43 +09:00
Ophestra Umiker 4e1e343081
library: io: implement client type and I/O methods
Path discovery is ported directly from Discord's C++ example, Windows has a crazy looking socket path that needs special syscall magic to dial, so we'll put that off for the time being.

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