-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from kalm/v3.2.3
v3.2.3
- Loading branch information
Showing
22 changed files
with
292 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
declare module '@kalm/ipc' { | ||
interface IPCConfig { | ||
socketTimeout?: number | ||
path?: string | ||
} | ||
|
||
interface KalmTransport { | ||
(params: any, emitter: NodeJS.EventEmitter): Socket | ||
} | ||
|
||
type Remote = { | ||
host: string | ||
port: number | ||
} | ||
|
||
type SocketHandle = NodeJS.Socket | ||
|
||
interface Socket { | ||
bind: () => void | ||
remote: (handle: SocketHandle) => Remote | ||
connect: (handle?: SocketHandle) => SocketHandle | ||
stop: () => void | ||
send: (handle: SocketHandle, message: number[] | Buffer) => void | ||
disconnect: (handle: SocketHandle) => void | ||
} | ||
|
||
export default function ipc(config?: IPCConfig): (config?: IPCConfig) => Transport; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
declare module 'kalm' { | ||
interface ClientConfig { | ||
label?: string | ||
routine?: KalmRoutine | ||
json?: Boolean | ||
transport?: KalmTransport | ||
port?: number | ||
host?: string | ||
isServer?: boolean | ||
provider?: any | ||
} | ||
|
||
interface ProviderConfig { | ||
label?: string | ||
routine?: KalmRoutine | ||
json?: Boolean | ||
transport?: KalmTransport | ||
port?: number | ||
host?: string | ||
} | ||
|
||
type Remote = { | ||
host: string | ||
port: number | ||
} | ||
|
||
interface Provider extends NodeJS.EventEmitter { | ||
broadcast: (channel: string, message: Serializable) => void | ||
label: string | ||
stop: () => void | ||
connections: Client[] | ||
} | ||
|
||
interface Client extends NodeJS.EventEmitter { | ||
write: (channel: string, message: Serializable) => void | ||
destroy: () => void | ||
subscribe: (channel: string, handler: (body: any, frame: Frame) => any) => void | ||
unsubscribe: (channel: string, handler: (body: any, frame: Frame) => any) => void | ||
local: () => Remote | ||
remote: () => Remote | ||
} | ||
|
||
type Channel = { | ||
queue: Queue | ||
emitter: NodeJS.EventEmitter | ||
} | ||
|
||
type ChannelList = { | ||
[key: string]: Channel | ||
} | ||
|
||
type Serializable = Buffer | object | string | null | ||
|
||
type UDPSocketHandle = { | ||
socket: any | ||
port: number | ||
host: string | ||
} | ||
type UDPClient = { | ||
client: Client | ||
timeout: NodeJS.Timeout | ||
data: Buffer[] | ||
} | ||
type UDPClientList = { | ||
[key: string]: UDPClient | ||
} | ||
|
||
type SocketHandle = NodeJS.Socket | UDPSocketHandle | WebSocket | ||
|
||
interface KalmRoutine { | ||
(channel: string, params: any, channelEmitter: NodeJS.EventEmitter, clientEmitter: NodeJS.EventEmitter): Queue | ||
} | ||
interface Queue { | ||
add: (packet: Buffer) => void | ||
size: () => number | ||
flush: () => void | ||
} | ||
|
||
interface KalmTransport { | ||
(params: any, emitter: NodeJS.EventEmitter): Socket | ||
} | ||
interface Socket { | ||
bind: () => void | ||
remote: (handle: SocketHandle) => Remote | ||
connect: (handle?: SocketHandle) => SocketHandle | ||
stop: () => void | ||
send: (handle: SocketHandle, message: number[] | Buffer) => void | ||
disconnect: (handle: SocketHandle) => void | ||
} | ||
|
||
interface IPCConfig { | ||
socketTimeout?: number | ||
path?: string | ||
} | ||
|
||
interface TCPConfig { | ||
socketTimeout?: number | ||
} | ||
|
||
interface UDPConfig { | ||
type?: string | ||
localAddr?: string | ||
reuseAddr?: boolean | ||
socketTimeout?: number | ||
connectTimeout?: number | ||
} | ||
|
||
interface WSConfig { | ||
cert?: string | ||
key?: string | ||
secure?: boolean | ||
} | ||
|
||
type RawFrame = { | ||
frameId: number | ||
channel: string | ||
packets: Buffer[] | ||
payloadBytes: number | ||
} | ||
|
||
type Frame = { | ||
client: Client | ||
channel: string | ||
frame: { | ||
id: number | ||
messageIndex: number | ||
payloadBytes: number | ||
payloadMessages: number | ||
} | ||
} | ||
|
||
export const listen: (config: ProviderConfig) => Provider; | ||
export const connect: (config: ClientConfig) => Client; | ||
export const Routines: { | ||
tick: (config: { hz: number, seed?: number }) => KalmRoutine | ||
dynamic: (config: { hz: number, maxPackets?: number }) => KalmRoutine | ||
realtime: () => KalmRoutine | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
declare module '@kalm/tcp' { | ||
interface TCPConfig { | ||
socketTimeout?: number | ||
} | ||
|
||
interface KalmTransport { | ||
(params: any, emitter: NodeJS.EventEmitter): Socket | ||
} | ||
|
||
type Remote = { | ||
host: string | ||
port: number | ||
} | ||
|
||
type SocketHandle = NodeJS.Socket | ||
|
||
interface Socket { | ||
bind: () => void | ||
remote: (handle: SocketHandle) => Remote | ||
connect: (handle?: SocketHandle) => SocketHandle | ||
stop: () => void | ||
send: (handle: SocketHandle, message: number[] | Buffer) => void | ||
disconnect: (handle: SocketHandle) => void | ||
} | ||
|
||
export default function tcp(config?: TCPConfig): (config?: TCPConfig) => Transport; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
declare module '@kalm/udp' { | ||
interface UDPConfig { | ||
type?: string | ||
localAddr?: string | ||
reuseAddr?: boolean | ||
socketTimeout?: number | ||
connectTimeout?: number | ||
} | ||
|
||
interface KalmTransport { | ||
(params: any, emitter: NodeJS.EventEmitter): Socket | ||
} | ||
|
||
type Remote = { | ||
host: string | ||
port: number | ||
} | ||
|
||
type SocketHandle = { | ||
socket: any | ||
port: number | ||
host: string | ||
} | ||
|
||
interface Socket { | ||
bind: () => void | ||
remote: (handle: SocketHandle) => Remote | ||
connect: (handle?: SocketHandle) => SocketHandle | ||
stop: () => void | ||
send: (handle: SocketHandle, message: number[] | Buffer) => void | ||
disconnect: (handle: SocketHandle) => void | ||
} | ||
|
||
export default function udp(config?: UDPConfig): (config?: UDPConfig) => Transport; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.