Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket for Client Service API #506

Merged
merged 23 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eac6153
feat: creating `ClientServer` implementation
tegefaulkes Feb 14, 2023
c433d92
feat: `ClientServer` supports backpressure
tegefaulkes Feb 17, 2023
0ed77d6
fix: switched `ClientServer` to `StartStop` and other fixes
tegefaulkes Feb 20, 2023
485e4a8
feat: creating `ClientClient` implementation
tegefaulkes Feb 20, 2023
52500ca
feat: client authenticates server
tegefaulkes Feb 21, 2023
eba92b2
tests: re-ordering tests
tegefaulkes Feb 21, 2023
e092e64
tests: tests for abrupt connection ending
tegefaulkes Feb 21, 2023
17cb110
feat: client rejects normal HTTP requests
tegefaulkes Feb 21, 2023
c21ebd1
feat: `ClientClient` connection timeout
tegefaulkes Feb 22, 2023
4ceb657
tests: testing abruptly dropped connections
tegefaulkes Feb 22, 2023
d80ad80
feat: `ClientClient` keepalive and heartbeat
tegefaulkes Feb 23, 2023
2d01f27
feat: `ClientServer` keepalive and heartbeat
tegefaulkes Feb 23, 2023
5da726e
feat: `IPv6` support
tegefaulkes Feb 23, 2023
d096ce2
fix: cleaning up and errors
tegefaulkes Feb 23, 2023
1641c7e
tests: cleaning up and fixing tests
tegefaulkes Feb 24, 2023
d2eea49
feat: stream handler callback provided with `ConnectionInfo`
tegefaulkes Feb 24, 2023
00a2094
fix: changed names of `ClientClient` and `ClientServer` to `WebSocket…
tegefaulkes Feb 27, 2023
0f9cbcd
fix: `WebSocketServer` using protected arrow functions for the `uWebs…
tegefaulkes Feb 27, 2023
4a4427a
feat: `WebSocketClient` now extends the `WebSocketStream` class for i…
tegefaulkes Feb 27, 2023
bf3627b
feat: `WebSocketServer` now extends the `WebSocketStream` class for i…
tegefaulkes Feb 27, 2023
953efbc
fix: separating the `websockets` code to its own domain
tegefaulkes Feb 28, 2023
f260d73
fix: abstracting `uWebsocket` server creation to its own protected me…
tegefaulkes Feb 28, 2023
c6feceb
feat: `WebSocketServer` now extends `EventTarget` with `connection`, …
tegefaulkes Feb 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"tslib": "^2.4.0",
"tsyringe": "^4.7.0",
"utp-native": "^2.5.3",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.19.0",
"ws": "^8.12.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/RPC/RPCServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import type {
RawHandlerImplementation,
ServerHandlerImplementation,
UnaryHandlerImplementation,
ConnectionInfo,
} from './types';
import type { ReadableWritablePair } from 'stream/web';
import type { JSONValue } from '../types';
import type { ConnectionInfo } from '../network/types';
import type { RPCErrorEvent } from './utils';
import type { MiddlewareFactory } from './types';
import { ReadableStream } from 'stream/web';
Expand Down
2 changes: 1 addition & 1 deletion src/RPC/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { JSONValue } from 'types';
import type { ContainerType } from 'RPC/types';
import type { ReadableStream } from 'stream/web';
import type { JsonRpcRequest } from 'RPC/types';
import type { ConnectionInfo } from '../network/types';
import type { ConnectionInfo } from './types';
import type { ContextCancellable } from '../contexts/types';

abstract class Handler<
Expand Down
22 changes: 21 additions & 1 deletion src/RPC/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { JSONValue } from '../types';
import type { ConnectionInfo } from '../network/types';
import type { ContextCancellable } from '../contexts/types';
import type { ReadableStream, ReadableWritablePair } from 'stream/web';
import type { Handler } from './handlers';
Expand All @@ -11,6 +10,8 @@ import type {
ClientCaller,
UnaryCaller,
} from './callers';
import type { NodeId } from '../nodes/types';
import type { Certificate } from '../keys/types';

/**
* This is the JSON RPC request object. this is the generic message type used for the RPC.
Expand Down Expand Up @@ -108,6 +109,24 @@ type JsonRpcMessage<T extends JSONValue = JSONValue> =
| JsonRpcRequest<T>
| JsonRpcResponse<T>;

/**
* Proxy connection information
* @property remoteNodeId - NodeId of the remote connecting node
* @property remoteCertificates - Certificate chain of the remote connecting node
* @property localHost - Proxy host of the local connecting node
* @property localPort - Proxy port of the local connecting node
* @property remoteHost - Proxy host of the remote connecting node
* @property remotePort - Proxy port of the remote connecting node
*/
type ConnectionInfo = Partial<{
remoteNodeId: NodeId;
remoteCertificates: Array<Certificate>;
localHost: string;
localPort: number;
remoteHost: string;
remotePort: number;
}>;

// Handler types
type HandlerImplementation<I, O> = (
input: I,
Expand Down Expand Up @@ -218,6 +237,7 @@ export type {
JsonRpcRequest,
JsonRpcResponse,
JsonRpcMessage,
ConnectionInfo,
HandlerImplementation,
RawHandlerImplementation,
DuplexHandlerImplementation,
Expand Down
Loading