@@ -41,7 +41,7 @@ interface ErrorResponse {
4141 message : string ;
4242}
4343
44- interface GobanSocketOptions {
44+ export interface GobanSocketOptions {
4545 /** Don't automatically send pings */
4646 dont_ping ?: boolean ;
4747
@@ -67,6 +67,37 @@ const DEFAULT_PING_INTERVAL = 10000;
6767export type DataArgument < Entry > = Entry extends ( ...args : infer A ) => void ? A [ 0 ] : never ;
6868export type ProtocolResponseType < Entry > = Entry extends ( ...args : any [ ] ) => infer R ? R : never ;
6969
70+ /**
71+ * Interface describing the public API of a GobanSocket (or compatible proxy).
72+ * Both GobanSocket and GobanSocketProxy satisfy this interface.
73+ * Extends EventEmitter<GobanSocketEvents> so on/off/emit types match exactly.
74+ */
75+ export interface IGobanSocket <
76+ SendProtocol extends ClientToServerBase = ClientToServer ,
77+ RecvProtocol = ServerToClient ,
78+ > extends EventEmitter < GobanSocketEvents > {
79+ readonly url : string ;
80+ clock_drift : number ;
81+ latency : number ;
82+ options : GobanSocketOptions ;
83+ readonly connected : boolean ;
84+
85+ send < Command extends keyof SendProtocol > (
86+ command : Command ,
87+ data : DataArgument < SendProtocol [ Command ] > ,
88+ cb ?: ( data : ProtocolResponseType < SendProtocol [ Command ] > , error ?: any ) => void ,
89+ ) : void ;
90+
91+ sendPromise < Command extends keyof SendProtocol > (
92+ command : Command ,
93+ data : DataArgument < SendProtocol [ Command ] > ,
94+ ) : Promise < ProtocolResponseType < SendProtocol [ Command ] > > ;
95+
96+ authenticate ( authentication : DataArgument < SendProtocol [ "authenticate" ] > ) : void ;
97+ disconnect ( ) : void ;
98+ ping ( ) : void ;
99+ }
100+
70101/**
71102 * This is a simple wrapper around the WebSocket API that provides a
72103 * simple interface to connect to the Online-Go.com servers. It provides:
0 commit comments