Remove instance id generics
Instead, all instance ids are now usize (like message ids). This allows me to enforce the fact that no two instances of a Bot must have the same id by generating the ids in the Bot. Reusing the same id for multiple instances that send their events to the same place can lead to race conditions depending on how events are handled. For example, the old instance might still be shutting down while the new instance is already connected to a room, leading to an InstanceEvent::Stopped from the old instance that seemingly applies to the new instance.
This commit is contained in:
parent
17ff660ab2
commit
8377695529
4 changed files with 68 additions and 83 deletions
|
|
@ -77,7 +77,7 @@ async fn run() -> anyhow::Result<()> {
|
|||
.instance("test")
|
||||
.with_username("examplebot");
|
||||
|
||||
bot.add_instance((), config);
|
||||
bot.add_instance(config);
|
||||
|
||||
while let Some(event) = bot.recv().await {
|
||||
if let BotEvent::Packet { conn, packet, .. } = event {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue