@babblevoice/babble-drachtio-callmanager 3.7.30 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +6 -0
- package/Dockerfile +52 -0
- package/README.md +33 -13
- package/lib/call.js +3 -5
- package/package.json +2 -4
package/.dockerignore
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# babble-drachtio-callmanager test image
|
|
2
|
+
#
|
|
3
|
+
# callmanager talks to projectrtp as a client, but its interface tests boot a
|
|
4
|
+
# real local engine (projectrtp.run()). @babblevoice/projectrtp 3.x is a Rust
|
|
5
|
+
# napi addon shipped as source (rust/ + libilbc/) with no install hook, so we
|
|
6
|
+
# compile it in a rust-builder stage and drop the resulting .so into
|
|
7
|
+
# node_modules/@babblevoice/projectrtp/build/Release/ — then run the suite
|
|
8
|
+
# against the real engine (no mocking). Mirrors babble-rtp's Dockerfile.
|
|
9
|
+
#
|
|
10
|
+
# docker build --target test -t callmanager:test .
|
|
11
|
+
# docker run --rm callmanager:test
|
|
12
|
+
# docker run --rm callmanager:test npx mocha --recursive --check-leaks --grep '486'
|
|
13
|
+
|
|
14
|
+
# --- Stage 1: install node deps (incl. dev deps for the test run) -----------
|
|
15
|
+
FROM alpine:3.22 AS deps
|
|
16
|
+
WORKDIR /usr/src/callmanager/
|
|
17
|
+
RUN apk add --no-cache nodejs npm
|
|
18
|
+
COPY package.json package-lock.json ./
|
|
19
|
+
# --ignore-scripts: projectrtp 3.x has no install hook; we build the Rust
|
|
20
|
+
# addon ourselves in the next stage.
|
|
21
|
+
RUN npm ci --ignore-scripts
|
|
22
|
+
|
|
23
|
+
# --- Stage 2: build the Rust napi cdylib + libilbc --------------------------
|
|
24
|
+
# Pinned to rust 1.92 to match projectrtp's own build.
|
|
25
|
+
FROM rust:1.92-alpine3.22 AS rust-builder
|
|
26
|
+
WORKDIR /src
|
|
27
|
+
RUN apk add --no-cache musl-dev pkgconfig cmake build-base linux-headers spandsp3-dev
|
|
28
|
+
COPY --from=deps /usr/src/callmanager/node_modules/@babblevoice/projectrtp/libilbc/ /src/libilbc/
|
|
29
|
+
RUN mkdir -p /src/libilbc/_build && \
|
|
30
|
+
cd /src/libilbc/_build && \
|
|
31
|
+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
|
|
32
|
+
make -j"$(nproc)" && make install && \
|
|
33
|
+
ldconfig /usr/local/lib 2>/dev/null || true
|
|
34
|
+
COPY --from=deps /usr/src/callmanager/node_modules/@babblevoice/projectrtp/rust/ /src/rust/
|
|
35
|
+
WORKDIR /src/rust
|
|
36
|
+
# Alpine's rust defaults to musl with +crt-static; a cdylib loaded by Node at
|
|
37
|
+
# runtime needs dynamic linkage, so override.
|
|
38
|
+
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
|
39
|
+
RUN cargo build --release
|
|
40
|
+
|
|
41
|
+
# --- Stage 3: test image ----------------------------------------------------
|
|
42
|
+
FROM alpine:3.22 AS test
|
|
43
|
+
WORKDIR /usr/src/callmanager/
|
|
44
|
+
RUN apk add --no-cache nodejs npm spandsp3 libstdc++ libc6-compat ca-certificates
|
|
45
|
+
COPY --from=deps /usr/src/callmanager/node_modules ./node_modules
|
|
46
|
+
COPY --from=rust-builder /usr/local/lib/libilbc.so* /usr/lib/
|
|
47
|
+
COPY --from=rust-builder /src/rust/target/release/libprojectrtp.so \
|
|
48
|
+
./node_modules/@babblevoice/projectrtp/build/Release/projectrtp.node
|
|
49
|
+
COPY package.json package-lock.json index.js ./
|
|
50
|
+
COPY lib/ ./lib/
|
|
51
|
+
COPY test/ ./test/
|
|
52
|
+
CMD [ "npm", "test" ]
|
package/README.md
CHANGED
|
@@ -162,28 +162,48 @@ npm link projectrtp
|
|
|
162
162
|
npm link babble-drachtio-registrar
|
|
163
163
|
npm link babble-drachtio-auth
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
# Building and testing
|
|
166
|
+
|
|
167
|
+
The interface tests boot a **real** projectrtp engine (`projectrtp.run()`) rather
|
|
168
|
+
than mocking it. `@babblevoice/projectrtp` 3.x is a Rust napi addon published as
|
|
169
|
+
source (`rust/` + `libilbc/`) with no install hook, so the native `.so` has to be
|
|
170
|
+
compiled and dropped into `node_modules/@babblevoice/projectrtp/build/Release/projectrtp.node`
|
|
171
|
+
before the suite can run. The `Dockerfile` does this in a `rust-builder` stage
|
|
172
|
+
(mirroring babble-rtp) so you don't need a local Rust/cmake toolchain.
|
|
173
|
+
|
|
174
|
+
Run the whole suite:
|
|
166
175
|
|
|
167
176
|
```bash
|
|
168
|
-
docker
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
npm test
|
|
177
|
+
docker build --target test -t callmanager:test .
|
|
178
|
+
docker run --rm callmanager:test
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Run a single test (override the default `npm test` command):
|
|
174
182
|
|
|
183
|
+
```bash
|
|
184
|
+
docker run --rm callmanager:test \
|
|
185
|
+
npx mocha --recursive --check-leaks --grep 'Create call and send 183 - early - SAVPF'
|
|
175
186
|
```
|
|
176
187
|
|
|
177
|
-
|
|
188
|
+
To iterate on test code without rebuilding the image each time, mount your working
|
|
189
|
+
tree over the source (the built engine in the image's `node_modules` is reused):
|
|
178
190
|
|
|
179
191
|
```bash
|
|
180
192
|
docker run --rm -it \
|
|
181
|
-
-
|
|
182
|
-
-v "$(pwd)":/usr/src/
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
-v "$(pwd)/lib":/usr/src/callmanager/lib:Z \
|
|
194
|
+
-v "$(pwd)/test":/usr/src/callmanager/test:Z \
|
|
195
|
+
-v "$(pwd)/index.js":/usr/src/callmanager/index.js:Z \
|
|
196
|
+
callmanager:test
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Building the engine locally (no Docker)
|
|
186
200
|
|
|
201
|
+
If you have Rust + cmake installed you can build the addon straight into the
|
|
202
|
+
installed package and run the tests on the host:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
( cd node_modules/@babblevoice/projectrtp && npm run build ) # cargo build → build/Release/projectrtp.node
|
|
206
|
+
npm test
|
|
187
207
|
```
|
|
188
208
|
|
|
189
209
|
# References
|
package/lib/call.js
CHANGED
|
@@ -3798,19 +3798,17 @@ class call {
|
|
|
3798
3798
|
return this
|
|
3799
3799
|
}
|
|
3800
3800
|
|
|
3801
|
-
const hangups = []
|
|
3802
3801
|
if( this.parent ) {
|
|
3802
|
+
const hangups = []
|
|
3803
3803
|
for( const child of this.parent.children ) {
|
|
3804
3804
|
if( child !== this ) {
|
|
3805
3805
|
child.detach()
|
|
3806
|
-
/* do not await - we do not want to delay the winner in
|
|
3807
|
-
connecting by waiting for the completion of the hangups */
|
|
3808
3806
|
hangups.push( child.hangup( hangupcodes.LOSE_RACE ) )
|
|
3809
3807
|
}
|
|
3810
3808
|
}
|
|
3809
|
+
/* do not block the winner - race losers complete in background */
|
|
3810
|
+
Promise.all( hangups ).catch( ( e ) => console.error( e ) )
|
|
3811
3811
|
}
|
|
3812
|
-
|
|
3813
|
-
await Promise.all( hangups )
|
|
3814
3812
|
callstore.set( this )
|
|
3815
3813
|
|
|
3816
3814
|
if ( this._dialog.sip )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babblevoice/babble-drachtio-callmanager",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Call processing to create a PBX",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,10 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babblevoice/babble-drachtio-auth": "^1.0.2",
|
|
24
|
+
"@babblevoice/projectrtp": "^3.2.2",
|
|
24
25
|
"drachtio-srf": "^4.4.47",
|
|
25
26
|
"uuid": "^8.3.2"
|
|
26
27
|
},
|
|
27
|
-
"optionalDependencies": {
|
|
28
|
-
"@babblevoice/projectrtp": "^2.6.2"
|
|
29
|
-
},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
|
32
30
|
"chai": "^4.3.6",
|