1***@qq.com
1***@qq.com
  • 发布:2024-12-30 14:59
  • 更新:2024-12-31 11:13
  • 阅读:30

SSEChannel调试报错not found collection

分类:uniCloud

在调试uniCloud.SSEChannel过程中(已开通unipush2)遇到报错:{"code":"FUNCTION_EXCUTE_ERROR","message":"not found collection"}
求大佬解答 。

客户端代码:

async function testSSE() {  
  const sseChannel = new uniCloud.SSEChannel(); // 创建消息通道  
  console.log(sseChannel);  
  await sseChannel.open(); // 等待通道开启  
  sseChannel.on("message", (message) => {  
    // 监听message事件  
    console.log("on message", message);  
    list.value.push(JSON.stringify(e.data));  
  });  
  sseChannel.on("end", (message) => {  
    // 监听end事件,如果云端执行end时传了message,会在客户端end事件内收到传递的消息  
    console.log("on end", message);  
    sseChannel.close();  
  });  

  const myTestObj = uniCloud.importObject("myTest");  
  await myTestObj  
    .testSSE({  
      messages: "123",  
      sseChannel, // 调用云对象时传入通道对象  
    })  
    .then((res) => {  
      console.log(res);  
    })  
    .catch((err) => {  
      console.log(err);  
    });  
}

云对象代码:

async testSSE({  
        messages,  
        sseChannel,  
    }) {  
        return new Promise(async (resolve, reject) => {  
            try {  
                console.log(messages, sseChannel);  
                const channel = uniCloud.deserializeSSEChannel(sseChannel);  
                console.log(channel);  
                await channel.write({  
                    a: 1,  
                });  
                await channel.write({  
                    a: 2,  
                });  
                await channel.write({  
                    a: 3,  
                });  
                await channel.write({  
                    a: 4,  
                });  

                console.log(res);  
                await channel.end({  
                    a: 5,  
                });  
                resolve({  
                    errCode: 0,  
                });  
            } catch (e) {  
                reject(e);  
            }  
        });  
    },

云对象配置信息:
{
"name": "myTest",
"dependencies": {},
"extensions": {
"uni-cloud-jql": {},
"uni-cloud-push": {}
}
}

2024-12-30 14:59 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

手动创建一下集合试下呢

要回复问题请先登录注册