Skip to content

Commit 1f9e38a

Browse files
committed
feat: Implement ListBindings request and BindingsList response
1 parent e8f3eb0 commit 1f9e38a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/gmcp/Client/Keystrokes.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class GMCPMessageClientKeystrokesUnbindAll extends GMCPMessage {
2828
// No specific properties needed for this message
2929
}
3030

31+
// Message class for the server's request to list bindings
32+
class GMCPMessageClientKeystrokesListBindings extends GMCPMessage {
33+
// No specific properties needed for this message
34+
}
35+
3136
export class GMCPClientKeystrokes extends GMCPPackage {
3237
public packageName: string = "Client.Keystrokes";
3338
private bindings: KeyBinding[] = [];
@@ -165,6 +170,15 @@ export class GMCPClientKeystrokes extends GMCPPackage {
165170
this.unbindAll();
166171
}
167172

173+
// Handler for the server's request to list bindings
174+
public handleListBindings(data: GMCPMessageClientKeystrokesListBindings): void {
175+
// data parameter is unused but kept for consistency
176+
console.log("Received Client.Keystrokes.ListBindings request, sending current bindings."); // Optional logging
177+
const bindingsArray = this.listBindings();
178+
// Send the list back using the "BindingsList" message name
179+
this.sendData("BindingsList", bindingsArray);
180+
}
181+
168182
public listBindings(): KeyBinding[] {
169183
return [...this.bindings];
170184
}

0 commit comments

Comments
 (0)