-
-
Save avneesh0612/65ca14d20549303d0a08da2daebb96cb to your computer and use it in GitHub Desktop.
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
import { getSSLHubRpcClient, HubEventType } from "@farcaster/hub-nodejs"; | |
const hubRpcEndpoint = "YOUR_GRPC_URL"; | |
const client = getSSLHubRpcClient(hubRpcEndpoint); | |
client.$.waitForReady(Date.now() + 5000, async (e) => { | |
if (e) { | |
console.error(`Failed to connect to ${hubRpcEndpoint}:`, e); | |
process.exit(1); | |
} else { | |
console.log(`Connected to ${hubRpcEndpoint}`); | |
const subscribeResult = await client.subscribe({ | |
eventTypes: [HubEventType.MERGE_MESSAGE], | |
}); | |
if (subscribeResult.isOk()) { | |
const stream = subscribeResult.value; | |
for await (const event of stream) { | |
if (event.mergeMessageBody.message.data.type === 1) { | |
console.log(event.mergeMessageBody.message.data.castAddBody.text); | |
} | |
} | |
} | |
client.close(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment