-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make a client-server example, not force use of IDs
- Loading branch information
v1rtl
committed
Jun 4, 2023
1 parent
0d69e98
commit 0f553c2
Showing
10 changed files
with
98 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"fmt": { | ||
"useTabs": false, | ||
"lineWidth": 80, | ||
"indentWidth": 2, | ||
"singleQuote": true, | ||
"semiColons": false | ||
"useTabs": false, | ||
"lineWidth": 80, | ||
"indentWidth": 2, | ||
"singleQuote": true, | ||
"semiColons": false | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import { lazyJSONParse } from '../utils.ts' | ||
|
||
const socket = new WebSocket('ws://localhost:8080') | ||
|
||
socket.onopen = () => { | ||
if (socket.readyState === socket.OPEN) { | ||
socket.send( | ||
JSON.stringify({ method: 'hello', params: ['world'], jsonrpc: '2.0' }), | ||
) | ||
} | ||
} | ||
|
||
socket.onmessage = (ev) => { | ||
console.log(lazyJSONParse(ev.data)) | ||
socket.close() | ||
} |
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,11 @@ | ||
import { App } from '../mod.ts' | ||
|
||
const app = new App() | ||
|
||
app.method<[string]>('hello', (params) => { | ||
return `Hello ${params[0]}` | ||
}) | ||
|
||
await app.listen({ port: 8080, hostname: '0.0.0.0' }, (addr) => { | ||
console.log(`Listening on ${addr.port}`) | ||
}) |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './server.ts' | ||
export * from './app.ts' | ||
export * from './request.ts' | ||
export type { ErrorResponse, JsonRpcRequest, RPCOptions } from './types.ts' |
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