mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +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
|
||||
*/
|
||||
export class Request<P extends any[], M extends string = string> {
|
||||
export interface Request<P extends any[], M extends string = string> {
|
||||
id?: ReqId
|
||||
method: M
|
||||
params: P
|
||||
|
||||
constructor (method: M, params: P, id?: ReqId) {
|
||||
this.method = method
|
||||
this.params = params
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Request, readResponse, serialize } from '@anticrm/platform'
|
||||
import { readResponse, serialize } from '@anticrm/platform'
|
||||
import { start, _Token } from '../server'
|
||||
import { encode } from 'jwt-simple'
|
||||
import WebSocket from 'ws'
|
||||
@ -43,7 +43,6 @@ describe('server', () => {
|
||||
it('should not connect to server without token', (done) => {
|
||||
const conn = new WebSocket('ws://localhost:3333/xyz')
|
||||
conn.on('error', () => {
|
||||
console.log('error')
|
||||
conn.close()
|
||||
done()
|
||||
})
|
||||
@ -55,7 +54,7 @@ describe('server', () => {
|
||||
// const start = Date.now()
|
||||
conn.on('open', () => {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user