當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。