Skip to content

Commit

Permalink
add emit to agent
Browse files Browse the repository at this point in the history
  • Loading branch information
parzival418 committed Nov 22, 2024
1 parent bbc2753 commit fb71229
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/server/agents/src/lib/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,23 @@ type ChannelEvents = {
class Channel extends (EventEmitter as new () => TypedEmitter<ChannelEvents>) {
constructor(private channelId: string, private agent: Agent) {
super()
this.agent = agent
}

emit<K extends keyof ChannelEvents>(
event: K,
data: Parameters<ChannelEvents[K]>[0]
): boolean {
const eventData = {
return super.emit(event, ...([data] as Parameters<ChannelEvents[K]>))
}

emitToAgent<K extends keyof AgentEvents>(
event: K,
data: Parameters<AgentEvents[K]>[0]
): boolean {
return this.agent.emit(event, {
...data,
channel: this.channelId,
}
return this.agent.emit(event, eventData)
})
}
}

Expand Down

0 comments on commit fb71229

Please sign in to comment.