import { methods , Socket , SocketType } from "./native" ; import { Message , MessageLike , Readable , SocketOptions , Writable } from "." ; const { send , receive , join , leave } = methods ; export class Server extends Socket { constructor ( options ? ) { super ( SocketType . Server , options ) ; } } interface ServerRoutingOptions { routingId : number ; } export interface Server extends Readable < [ Message , ServerRoutingOptions ] > , Writable < MessageLike , [ ServerRoutingOptions ] > { } Object . assign ( Server . prototype , { send , receive } ) ; export class Client extends Socket { constructor ( options ? ) { super ( SocketType . Client , options ) ; } } export interface Client extends Readable < [ Message ] > , Writable < MessageLike > { } Object . assign ( Client . prototype , { send , receive } ) ; export class Radio extends Socket { constructor ( options ? ) { super ( SocketType . Radio , options ) ; } } interface RadioGroupOptions { group : Buffer | string ; } export interface Radio extends Writable < MessageLike , [ RadioGroupOptions ] > { } Object . assign ( Radio . prototype , { send } ) ; export class Dish extends Socket { constructor ( options ? ) { super ( SocketType . Dish , options ) ; } join ( ... values ) { for ( const value of values ) join . call ( this , value ) ; } leave ( ... values ) { for ( const value of values ) leave . call ( this , value ) ; } } interface DishGroupOptions { group : Buffer ; } export interface Dish extends Readable < [ Message , DishGroupOptions ] > { } Object . assign ( Dish . prototype , { receive } ) ; export class Gather extends Socket { constructor ( options ? ) { super ( SocketType . Gather , options ) ; } } export interface Gather extends Readable < [ Message ] > { conflate : boolean ; } Object . assign ( Gather . prototype , { receive } ) ; export class Scatter extends Socket { constructor ( options ? ) { super ( SocketType . Scatter , options ) ; } } export interface Scatter extends Writable < MessageLike > { conflate : boolean ; } Object . assign ( Scatter . prototype , { send } ) ; export class Datagram extends Socket { constructor ( options ? ) { super ( SocketType . Datagram , options ) ; } } export interface Datagram extends Readable < [ Message , Message ] > , Writable < [ MessageLike , MessageLike ] > { } Object . assign ( Datagram . prototype , { send , receive } ) ;