Skip to content

Create an interface for our GobanSocket#226

Merged
anoek merged 2 commits intomainfrom
web-worker-socket
Feb 14, 2026
Merged

Create an interface for our GobanSocket#226
anoek merged 2 commits intomainfrom
web-worker-socket

Conversation

@anoek
Copy link
Member

@anoek anoek commented Feb 14, 2026

This is in preparation for moving GobanSocket stuff out to a WebWorker

@github-actions
Copy link

Code Review - Type Consistency Issue

I found one type inconsistency that should be addressed:

Issue: options property type mismatch

In src/engine/GobanSocket.ts, the IGobanSocket interface defines options with an inline object type (lines 76-81), but the GobanSocket class uses GobanSocketOptions (line 90).

// Interface definition (inline type)
export interface IGobanSocket<...> {
    options: {
        dont_ping?: boolean;
        ping_interval?: number;
        timeout_delay?: number;
        quiet?: boolean;
    };
    // ...
}

// Class implementation (uses interface)
export class GobanSocket<...> {
    public options: GobanSocketOptions;
    // ...
}

Why this matters:

  • The interface duplicates type information instead of reusing GobanSocketOptions
  • If GobanSocketOptions is extended later, the interface won't reflect those changes
  • Any future proxy implementation would need to maintain duplicate type definitions

Recommendation:
Change the interface to use GobanSocketOptions:

export interface IGobanSocket<...> {
    options: GobanSocketOptions;
    // ...
}

Everything else in the PR looks good - the refactoring properly abstracts the socket interface and all usage sites are correctly updated.

@github-actions
Copy link

Code Review Summary

I've analyzed this PR and found no bugs or performance issues. The changes are well-structured and properly maintain type safety.

What This PR Does Well

Proper interface design: The IGobanSocket interface correctly extends EventEmitter<GobanSocketEvents>, which provides all necessary event methods (on, off, emit)

Complete API coverage: All public methods and properties used by consumers are included in the interface:

  • url, clock_drift, latency, options, connected
  • send(), sendPromise(), authenticate(), disconnect(), ping()
  • Event methods from EventEmitter (on, off)

Type safety maintained: The test file correctly updates to use explicit type parameters, ensuring the mock socket is properly typed

Export visibility: Correctly exports GobanSocketOptions interface so it can be referenced in the public API

This change successfully creates an abstraction that will enable moving GobanSocket to a WebWorker as stated in the PR description.

@anoek anoek merged commit 2cfb765 into main Feb 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants