mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-15 21:03:30 +00:00
refactor Request
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
1860280e49
commit
df797666ec
@ -24,15 +24,10 @@ export type ReqId = string | number
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export class Request<P extends any[], M extends string = string> {
|
export interface Request<P extends any[], M extends string = string> {
|
||||||
id?: ReqId
|
id?: ReqId
|
||||||
method: M
|
method: M
|
||||||
params: P
|
params: P
|
||||||
|
|
||||||
constructor (method: M, params: P, id?: ReqId) {
|
|
||||||
this.method = method
|
|
||||||
this.params = params
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { Request, readResponse, serialize } from '@anticrm/platform'
|
import { readResponse, serialize } from '@anticrm/platform'
|
||||||
import { start, _Token } from '../server'
|
import { start, _Token } from '../server'
|
||||||
import { encode } from 'jwt-simple'
|
import { encode } from 'jwt-simple'
|
||||||
import WebSocket from 'ws'
|
import WebSocket from 'ws'
|
||||||
@ -43,7 +43,6 @@ describe('server', () => {
|
|||||||
it('should not connect to server without token', (done) => {
|
it('should not connect to server without token', (done) => {
|
||||||
const conn = new WebSocket('ws://localhost:3333/xyz')
|
const conn = new WebSocket('ws://localhost:3333/xyz')
|
||||||
conn.on('error', () => {
|
conn.on('error', () => {
|
||||||
console.log('error')
|
|
||||||
conn.close()
|
conn.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@ -55,7 +54,7 @@ describe('server', () => {
|
|||||||
// const start = Date.now()
|
// const start = Date.now()
|
||||||
conn.on('open', () => {
|
conn.on('open', () => {
|
||||||
for (let i = 0; i < total; i++) {
|
for (let i = 0; i < total; i++) {
|
||||||
conn.send(serialize(new Request('ping', [], i)))
|
conn.send(serialize({ method: 'ping', params: [], id: i }))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let received = 0
|
let received = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user