Add sandbox and examples for SSE Session
This commit is contained in:
17
sandbox/sandbox-price-oracle.ts
Normal file
17
sandbox/sandbox-price-oracle.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { SSESession, type SSEvent } from '../source/sse-session/index.ts';
|
||||
|
||||
// Command: npx tsx ./sandbox/sandbox-price-oracle.ts
|
||||
|
||||
// Use the GP Price Oracle API
|
||||
const url = 'https://oracles.generalprotocols.com/sse/v1/messages';
|
||||
|
||||
// Create our sse session
|
||||
const sseSession = await SSESession.create(url);
|
||||
|
||||
// Create a message event handler
|
||||
sseSession.on('message', (message: SSEvent) => {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
// Connect to the SSESession
|
||||
await sseSession.connect();
|
||||
Reference in New Issue
Block a user