Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
add source to SocketServer sockets (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Dec 24, 2023
1 parent e97aef1 commit 04b8b17
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-sheep-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/experimental": patch
---

add source to SocketServer sockets
1 change: 1 addition & 0 deletions docs/modules/Socket.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface Socket {
readonly run: Effect.Effect<never, SocketError, void>
readonly writer: Effect.Effect<Scope.Scope, never, (chunk: Uint8Array) => Effect.Effect<never, never, void>>
readonly messages: Queue.Dequeue<Uint8Array>
readonly source?: unknown
}
```

Expand Down
1 change: 1 addition & 0 deletions src/Socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface Socket {
readonly run: Effect.Effect<never, SocketError, void>
readonly writer: Effect.Effect<Scope.Scope, never, (chunk: Uint8Array) => Effect.Effect<never, never, void>>
readonly messages: Queue.Dequeue<Uint8Array>
readonly source?: unknown
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/SocketServer/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export const make = (
})
)
),
Effect.flatMap((socket) => Queue.offer(queue, socket)),
Effect.flatMap((socket) => {
;(socket as any).source = conn
return Queue.offer(queue, socket)
}),
Effect.runFork
)
})
Expand Down Expand Up @@ -155,7 +158,10 @@ export const makeWebSocket = (
})
)
),
Effect.flatMap((socket) => Queue.offer(queue, socket)),
Effect.flatMap((socket) => {
;(socket as any).source = conn
return Queue.offer(queue, socket)
}),
Effect.runFork
)
})
Expand Down

0 comments on commit 04b8b17

Please sign in to comment.