当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript rockets-client.isJsonRpcRequest函数代码示例

本文整理汇总了TypeScript中rockets-client.isJsonRpcRequest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isJsonRpcRequest函数的具体用法?TypeScript isJsonRpcRequest怎么用?TypeScript isJsonRpcRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isJsonRpcRequest函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: expect

            mockServer.on('connection', () => {
                const task = brayns.request(INSPECT, [0, 1]);

                expect(isJsonRpcRequest(task.request)).toBe(true);
                expect(isFunction(task.then)).toBe(true);
                expect(isFunction(task.on)).toBe(true);
                expect(isFunction(task.cancel)).toBe(true);

                done();
            });
开发者ID:chevtche,项目名称:Brayns,代码行数:10,代码来源:client.spec.ts

示例2: toResponseErrorJson

                (socket as any).on('message', (data: any) => {
                    if (isString(data)) {
                        const json = fromJson<JsonRpcRequest<BinaryParams> | JsonRpcNotification<ChunkParams>>(data);

                        if (isJsonRpcRequest(json)) {
                            const response = toResponseErrorJson(json, {
                                code: -1,
                                message: 'Oops :('
                            });
                            socket.send(response);
                        } else if (isJsonRpcNotification(json)) {
                            notifications.push(json);
                        }
                    } else {
                        chunks.push(data);
                    }
                });
开发者ID:chevtche,项目名称:Brayns,代码行数:17,代码来源:client.spec.ts

示例3: toResponseJson

                (socket as any).on('message', (data: any) => {
                    messages.push(data);

                    if (isString(data)) {
                        const json = fromJson<JsonRpcRequest<BinaryParams> | JsonRpcNotification<ChunkParams>>(data);
                        if (isJsonRpcRequest(json)) {
                            request = json;
                        }
                    } else {
                        chunks.push(data);

                        if (chunks.length === expectedLength) {
                            // Received all chunks,
                            // respond so the request can complete
                            const response = toResponseJson(request, true);
                            socket.send(response);
                        }
                    }
                });
开发者ID:chevtche,项目名称:Brayns,代码行数:19,代码来源:client.spec.ts

示例4: fromJson

            }).then(() => {
                const [requestJson, ...objects] = messages;

                const request = fromJson(requestJson);
                expect(isJsonRpcRequest(request)).toBe(true);

                const notifications = objects.filter((obj, index) => index % 2 === 0)
                    .map(json => fromJson<JsonRpcNotification<ChunkParams>>(json));
                const chunks = objects.filter((obj, index) => index % 2 !== 0);

                expect(notifications).toHaveLength(expectedLength);
                expect(notifications.every(({method, params}) => method === CHUNK && isString(params!.id))).toBe(true);

                expect(chunks).toHaveLength(expectedLength);
                expect(chunks.every(chunk => chunk instanceof ArrayBuffer)).toBe(true);
                const json = decodeChunks(chunks);
                expect(json).toEqual(data);

                done();
            });
开发者ID:chevtche,项目名称:Brayns,代码行数:20,代码来源:client.spec.ts


注:本文中的rockets-client.isJsonRpcRequest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。