-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
timeout when get room payload #11
Comments
Yes! If we can not get the room payload, which means the room does not exist (from the program perspective), it will not be able to work anymore. Please feel free to submit a PR to improve it to be more robust if you have any good idea, thanks! |
I think we should use a recursive method to fetch all rooms.I had implemented the feature in Scala-wechaty. see https://github.com/wechaty/scala-wechaty/blob/3119df7f5bcb244bc8f9e6c5c4cd52faa04cf435/wechaty/src/main/scala/wechaty/plugins/RoomConnector.scala#L48 |
Thanks for the sharing! Will take a look into it later. |
maybe, shold waiting for all rooms to be ready, then send a message? return function OneToManyRoomConnectorPlugin (wechaty: Wechaty) {
log.verbose('WechatyPluginContrib', 'OneToManyRoomConnectorPlugin(%s) installing ...', wechaty)
let manyRoomList : Room[]
function waitingRoom(id: string): Promise<Room> {
return new Promise((resolve, reject) => {
const room = wechaty.Room.load(id)
if (room.isReady()) {
return resolve(room)
}
const timeoutTimer = setTimeout(() => {
finish()
return reject('timeout')
}, timeout);
const readyTimer = setInterval(() => {
if (room.isReady()) {
finish()
return resolve(room)
}
}, 100)
const finish = () => {
clearTimeout(timeoutTimer)
clearInterval(readyTimer)
}
})
}
wechaty.once('message', async onceMsg => {
log.verbose('WechatyPluginContrib', 'OneToManyRoomConnectorPlugin(%s) once(message) installing ...', wechaty)
if (!manyRoomList) {
const waitingRooms = config.many.map(id => waitingRoom(id)) // should make sure all rooms ready?
manyRoomList = Promise.all(waitingRooms) // await loadRoom(wechaty, config.many)
}
matchAndForward(onceMsg, manyRoomList)
wechaty.on('message', message => matchAndForward(message, manyRoomList))
})
} |
@chs97 When we need to say in a room, that room does not require to be ready-ed. The following code should work without any problem: const room = wechaty.Room.load('your_room_id@chatroom')
// The following code will work without any problem no matter whether the room is ready-ed or not
await room.say('hello') |
if room payload can't get successful, the message will send fail? and then, the roomConnector can't work actually? waiting for all rooms ready is a good choice? |
No. Whether the message can be sent successfully does not depend on the payload. You can send a message successfully without load any payload because the underlying Puppet API of the |
https://github.com/wechaty/wechaty-plugin-contrib/blob/05cfec3606480d2f2a544ac4e742a967bcaec2b4/src/contrib/room-connector/one-to-many-room-connector.ts#L105
If it's timeout to get room payload.the RoomConnector doesn't work!
The text was updated successfully, but these errors were encountered: