mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 05:07:43 +02:00
Allow Use client from client-resources from NodeJS (#545)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -30,6 +30,25 @@ export const clientId = 'client' as Plugin
|
||||
*/
|
||||
export type ClientHook = (client: Client) => Promise<Client>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ClientSocketFactory = (url: string) => ClientSocket
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ClientSocket {
|
||||
onmessage?: ((this: ClientSocket, ev: MessageEvent) => any) | null
|
||||
onclose?: ((this: ClientSocket, ev: CloseEvent) => any) | null
|
||||
onopen?: ((this: ClientSocket, ev: Event) => any) | null
|
||||
onerror?: ((this: ClientSocket, ev: Event) => any) | null
|
||||
|
||||
send: (data: string | ArrayBufferLike | Blob | ArrayBufferView) => void
|
||||
|
||||
close: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -38,7 +57,8 @@ export type ClientFactory = (token: string, endpoint: string) => Promise<Client>
|
||||
export default plugin(clientId,
|
||||
{
|
||||
metadata: {
|
||||
ClientHook: '' as Metadata<Resource<ClientHook>>
|
||||
ClientHook: '' as Metadata<Resource<ClientHook>>,
|
||||
ClientSocketFactory: '' as Metadata<ClientSocketFactory>
|
||||
},
|
||||
function: {
|
||||
GetClient: '' as Resource<ClientFactory>
|
||||
|
||||
Reference in New Issue
Block a user