查询客户端 - SDK7
SDK7的查询客户端是一个 RPC 客户端 与 查询服务器 追踪探寻的国家,并发送事件以取得进展.
设置
如果您想要为该项目做出贡献,则需要安装依赖并构建项目.
首先安装国家预防机制的依赖性:
$ npm install
该项目使用查询服务 原型定义 生成编译所需的代码,所以在开始开发前,确保您运行:
$ make build
使用量
这个库旨在被用在Decentraland Scene中,并使用用户认证等SDK7特性来初始化客户端.
您可以找到文档开始使用库 这里。 。 。 .
安装
向您的工程添加依赖性
$ npm add @dcl/quests-client
示例
创建查询客户端 executeTask 而如果基于钱包的认证是 OK, 您将准备使用客户端订阅更新或发送新的事件, 这些事件可能会在搜索中取得进展 .
例如,我们注册了两个可观察者来利用您代码中其他部分的客户端: questEventsObservable 财务报告和审定财务报表 questStartObservable
executeTask(async () => {
// retrieve websocket url from env
const ws = 'wss://quests-rpc.decentraland.zone'
const questID = 'q123-u456-e789-s012-t345'
// create quests client
try {
const client = await createQuestsClient(ws, questID)
questEventsObservable.on('message', async (action) => {
await client.sendEvent({ action })
})
questStartObservable.on('start', async () => {
await client.startQuest()
})
client.onStarted((quest) => {
// update your state here or react to the quest started event
})
client.onUpdate((quest) => {
// update your state here or react to the quest updates
})
// retrieve all quest instances and their state
const userInstance = client.getQuestInstance()
...
} catch (e) {
console.log(`[Your Scene] connection to ${ws} failed! ${e}`)
}
})
场景示例:查询跟踪
在这 仓库 您可以找到一个可以使用所有查询客户端功能的场景.
或者你去看看图书馆的文件 这里