Vai al contenuto principale

Lavoro a BeeBEEP circa 20 ore a settimana, ed è gratis per te. Sostienilo

Console events

Every event the console sends, what it carries, how to listen to some of them and how to catch up after a gap.

Per: sviluppatori · Da BeeBEEP 6.0.0 · Aggiornata il

Alcune pagine sono solo in inglese.

An event is a line BeeBEEP sends to a console connection, with no command asking for it: a user came online, a message arrived, a file moved on. This page is for whoever writes a bot or an integration, and gives the events with what each one carries. How to start the console and connect is on the console, and the commands are on the commands page.

How events arrive

An event is one line of JSON with the key event, and its fields under data:

{"event":"unreadCountChanged","data":{"chatId":1001,"unreadCount":1,"unreadMentions":0}}

Every connection is subscribed from the start: no command is needed to hear them. A line is an event when it has the key event, a reply when it has ok and the banner when it has banner; none has another's key.

Every event has a scope, the one a connection needs to hear it, and the events below are all heard at read and above. A connection that has not authenticated, at none, hears no event.

An event can arrive before the reply to the command that caused it, or right after it. send_message is followed by its own chatMessageAdded, and create_group by groupUpdated. A program that takes "the next line" for the reply to what it just sent sometimes reads an event instead: look for the key ok to find a reply, as the example does.

The one event a connection cannot avoid is consoleClosing, the farewell: it reaches every authenticated connection, whatever it subscribed to, as the last line before the end of the stream.

Subscribe to some events

subscribe with a list of names keeps only those events:

{"cmd":"subscribe","events":["chatMessageAdded","userConnected"]}

A plain subscribe, with no events, goes back to every event. A name that is unknown, or above the connection's scope, is refused by name with the code unknownEvent, and the filter stays as it was, so that a typo cannot filter everything out. An empty list is refused with invalidValue. A name given twice counts once. The filter survives a second auth.

unsubscribe stops the events of the connection and drops its filter; commands go on working. set with param notifications and value off is the same as unsubscribe, and on the same as subscribe.

A connection that does not read its events fast enough is closed (see the limits): a program that needs only a few events does well to subscribe to those.

What an event carries

An event's data holds only what happened. Its fields follow the rules of the commands: ids are whole numbers (userId, groupId, chatId), a uuid is text without braces, a time is milliseconds since 1970, and a field that has no value is a JSON null. Some events carry only an id, to say "go and look": userUpdated and groupUpdated do not say what changed, and the program reads the user with get_user or the group with get_group. chatMessageAdded carries a whole chat message object, the one described on the commands page, without its recipients; what happens to a message afterwards comes as what changed, with the names a person reads beside every id.

Catch up after a gap

No event is ever replayed. A connection that was unsubscribed, was closed because it read too slowly, or was not connected, has no way to learn what it missed. An event is a hint to look, never the record of what happened: when a program must be sure of the current state, it asks.

What you needAsk with
the users and who is onlinelist_users, or get_user for one
the groups and their memberslist_groups, or get_group for one
the messages of a chatget_chat_history, going back with oldestMessageId
what is unreadget_unread_counts
the files in transitlist_file_transfers, or get_file_transfer for one
your own statestatus

The events

Each table gives an event's name, the fields of its data, and what happened. help lists the names of the events a connection can hear, with the scope of each.

Users and connections

EventDataWhat happened
userConnecteduserIdA user came online.
userDisconnecteduserIdA user went offline.
userNotRespondinguserIdEvery connection to that user has stopped answering, though each is still open. The user stays online; this says so sooner than the timeout that closes a dead connection would.
userRespondingAgainuserIdThat user answered again after userNotResponding.
identityInUsetransport (network or bluetooth), addressAnother installation presents your profile with a different security key: BeeBEEP open on two devices at once, or someone else using your profile. address is the other device's, empty over Bluetooth. Said once per key in a session.
userUpdateduserIdSomething about that user changed. Read it again with get_user; the event does not carry the new value.
userRemoveduserIdBeeBEEP erased that user, who had no messages, no group and was neither a contact nor blocked. Nothing is left to read with get_user.
inactiveUsersRemovedhidden, erased, hiddenIds, erasedIds, daysOnce per cleanup of the users not seen for days days of use, when it did something: hidden users, kept for their messages, left out of list_users until they come back (userUpdated for each), and erased users who left nothing (userRemoved for each). A cleanup that found nobody sends nothing.
leaseExpireduuid, userIdNothing has been heard from that installation lately and no connection to it is open. userId is null when no user is known under that uuid. It never changes a user's status: a connection still means online.
nearbyHearduuid, userId, sourceA contact was recognised nearby over Bluetooth, one hop away, by what their device puts on the air (source is Nearby). Sent when they become nearby, not each time they are heard again. A hint, never a proof: it does not make the user online.
nearbyLostuuid, userId, sourceThat contact is no longer heard nearby over Bluetooth, or was blocked. leaseExpired follows when nothing else is left of them.
meshHearduuid, userId, sourceA contact's presence came over the Bluetooth mesh, through phones in between (source is Mesh). Sent when it starts, not each time it is heard again. A hint, never a proof: it does not make the user online, but their private texts can go over the mesh.
meshLostuuid, userId, sourceThat contact's presence over the Bluetooth mesh ran out, or they were blocked or removed. userId is null when no user is left under that uuid. leaseExpired follows when nothing else is left of them.
meshDeliveredmessageUuid, userIdA private text sent over the Bluetooth mesh was acknowledged by its recipient over the mesh: its receipt is now delivered (chatMessageReceiptChanged says so too).
lanFromBluetoothuserId, address, port, outcome, reasonWhat became of one network address a contact sent over Bluetooth, so that the two can talk over the local network instead. outcome is dialed (BeeBEEP is trying it), linked (a network connection came up after that try), unreachable (the try ended without a connection, for example on a network that keeps its devices apart; the address is not tried again for a while) or skipped (not tried). reason says why when skipped: alreadyLinked, otherNetwork, pending or unreachable; otherwise it is empty. Skipped addresses are reported only when they have just arrived, never at a later retry.
byeReceiveduuid, userIdThat installation announced that it is going away, with a signed goodbye BeeBEEP accepted. userId is null when no user is known under that uuid.
connectionProblemsinterfaceBeeBEEP hears nobody on that network interface (for example eth0) although a user went silent there, which points to this computer's side. While it lasts no user there is reported as not responding and nothing is closed.
connectionProblemsClearedinterfaceOver: something was heard on that interface again, or the interface went away.
peerCheckSentuserId, groupId, recipientsBeeBEEP is sure that a user stopped answering while its own connections work, and asked recipients other members of that group to check on them. One event for each group.
peerCheckReceivedfromUserId, userId, groupId, acted, reasonA member asked BeeBEEP to check on userId. acted is true when BeeBEEP schedules its own check, false when it ignores the hint, and reason then says why (reason is absent when acted is true). groupId is 0 for a group this installation does not know. A hint never changes anybody's status.
defaultChatSendingChangedallowed, onlineUsersPeak, reasonSending to BEEP, the room of whoever is online now, was refused (allowed false: too many people are online in it) or is allowed again. reason is the sentence to show while it is refused, empty when allowed. One event for each change; the room stays readable.

Chats and messages

EventDataWhat happened
chatMessageAddedmessageA new message in a chat, sent or received. message is the chat message object of the commands page, without its recipients. A message held in memory for lack of disk space comes twice: first with isTemporary true, then once it is saved. What happens to a message afterwards has events of its own.
chatMessageReceiptChangedchatId, chatName, chatKind, messageUuid, recipientId, recipientName, state, timestamp, reason, overallState, recipientCount, deliveredCount, readCountSomeone received (state Delivered) or read (Read) one of your messages, or a copy of it was given up (Failed). reason comes with Failed only: notDeliveredInTime (BEEP's copies wait 30 seconds), waitedTooLong (a copy waited past its term of active days) or recipientHidden (the recipient was hidden for inactivity). overallState and the counts say where the whole message stands, so the last event alone tells whether everyone has read it. A copy only written to the network (Sent) sends nothing.
chatMessagesMarkedReadchatId, chatName, chatKind, messageUuids, countYou read these received messages, in the app or with mark_read: one event for each marking, never one for each message. Someone else reading your message is chatMessageReceiptChanged.
waitingMessagesChangedchatId, messageCountThe messages of yours still waiting to be sent in this chat changed: one more, one fewer, or someone else they wait for. get_waiting_messages says for whom and why.
chatMessageRecipientsWithdrawnchatId, chatName, chatKind, messageUuid, recipientIds, recipientNames, reasonCopies of one of your messages were withdrawn: they are not sent and no longer count among its recipients. reason is outOfSight (members your circles no longer see), invitationExpired (a plugin's invitation that expired before it could leave) or deletedBySender (you deleted the message, for yourself or for everyone, before these copies left).
chatMessageReactionChangedchatId, chatName, chatKind, messageUuid, reactorId, reactorName, emoji, isRemoval, timestampA reaction on a message was set, replaced or removed, by this installation (reactorId 1) or by another user. emoji is the new one, empty with isRemoval true; timestamp is the reaction's own. Once per change: your own reaction reaching its recipients one by one sends nothing more.
chatMessageEditedchatId, chatName, chatKind, messageUuid, text, mentionsMe, editedAt, changeShownAtA message's sender changed its text, here (one of your messages, edit_message) or on another installation. text is the new text; editedAt the edit's stamp on the sender's clock (what orders two edits), 0 for one of yours edited before any copy was delivered (no "edited" mark); changeShownAt when it happened on this installation's clock, never before the message -- the time to show. Never a new message and never a notification.
chatMessageDeletedchatId, chatName, chatKind, messageUuid, senderId, senderName, deletedAt, changeShownAtA message's sender deleted it for everyone: the copy here is now the placeholder, its words gone. deletedAt is the sender's stamp, changeShownAt when it happened on this installation's clock (the time to show). A deleted message is never unread.
chatMessageChangeRefusedmessageUuid, change, reasonAn edit_message or a delete_message for everyone was refused (change edit or delete). reason: notFound, notOwn, notChangeable (an attachment, a forward, an invitation...), alreadyDeleted, turnedOff (the window is 0), tooLate, emptyText, tooLong or unchanged.
chatPollVoteChangedchatId, chatName, messageUuid, voterId, voterName, answers, isTakenBack, timestampA vote on a poll changed here: yours (vote_poll, voterId 1) or someone else's, cast, changed or taken back (answers empty, isTakenBack true). answers are the indexes chosen, from 0. Never a new message and never a notification.
chatPollClosedchatId, chatName, messageUuid, closedAt, votesA poll was closed, by you (close_poll) or by whoever asked it: votes is the final count, each entry voterId, voterName and answers; nobody can vote on it any more.
chatPollActRefusedmessageUuid, act, reasonA vote_poll or a close_poll was refused (act vote or close). reason: notFound, notPoll, closed, notMember, badAnswer or notAuthor.
chatMessageChangeMissedLegacyPeerschatId, chatName, messageUuid, change, peerIds, peerNamesOne of your messages was edited or deleted for everyone, and these recipients use BeeBEEP 5.x: on their side the message stays as it was.
chatClearedchatIdThe chat was emptied here (clear_chat, or Delete conversation on the chat's information): its messages are gone from this installation, its preview is empty, its unread count 0. The others keep theirs.
connectionTestSteptestId, step, verdict, code, detailsOne step of the running connection test (test_connection) has a verdict now, or a new one: one event per step that changed, a step still pending never said.
connectionTestFinishedas connection_test_statusThe connection test is over: running is false, and its cause and every step are final.
unreadCountChangedchatId, unreadCount, unreadMentionsThe number of unread messages of a chat changed. unreadMentions is how many of them mention you: your name, an @all, or a reply to one of your messages, in a group.
typingStateChangedchatId, senderId, isTyping, activitysenderId started or stopped typing in a chat, or switched between typing and recording a voice note. activity is Typing, RecordingVoice or Idle; isTyping is false for Idle. A refresh of the same activity sends nothing, and an activity that is not refreshed ends by itself.
notificationRaisednotificationBeeBEEP raised a notification of its own. notification holds type (always System), text, sourceId and timestamp.
chatSystemLinechatId, textA line BeeBEEP itself wrote in a chat, such as a notice that a message was not delivered. It is never a message: it is not in get_chat_history and has no chatMessageAdded.
chatArchivesImportedsourceFilePath, programVersion, error, chatsRead, added, alreadyHere, declined, linked, mediaCopied, mediaMissingThe saved chats of a BeeBEEP 5.x installation, read by import_legacy_installation, are stored as archives, after the import's own answer. error says why nothing was read; alreadyHere counts the chats an earlier import stored, declined those not stored because the disk is almost full (a later import tries them again), linked those shown in a chat here. list_archives already lists them.
presetMessagesChangedpresetMessagesYour preset messages changed: one was added, changed, removed or moved, the list was sorted, or it was read at the start. presetMessages is the whole list, as list_preset_messages gives it.

Files

EventDataWhat happened
fileTransferOfferReceivedmessageUuid, senderId, fileName, fileSize, contentHash, mimeTypeA user offered a file and a decision may be needed: answer with accept_file_transfer or reject_file_transfer, naming messageUuid.
fileTransferSameFileAskedactionId, chatId, chatName, fileNamesThe same file is still on its way in this chat. Nothing more is sent until answer_same_file_question says which one to cancel.
fileTransferWarningchatId, textA passing remark about a transfer of that chat, for example not to move or delete the file until it is sent. Not stored.
fileTransferErrormessageUuid, chatId, reasonAn offer made with send_file failed later, after the command answered, for example while the file was being read.
fileTransferProgressmessageUuid, peerUuid, direction, bytesTransferred, totalBytesHow far a transfer has come. At most one event for each transfer every 100 milliseconds, always the latest count, and the last one comes before the transfer's Completed.
fileTransferStateChangedmessageUuid, peerUuid, direction, stateA transfer moved to a new state: Offered, Accepted, Requesting, Transferring, Paused, Completed, Rejected, Failed or Canceled.
fileTransferRejectedmessageUuid, peerUuid, reasonA user declined a file this installation offered, and reason says why: UserDeclined, LocalPolicyBlocked, LocalError, AlreadyReceived, AlreadyDownloading, AwaitingDecision, FileTypeNotAllowed or LegacyPolicy (a 5.x recipient's settings, which do not say which one). It comes with the Rejected state change, and never for a decision of our own.
fileTransferUnavailablemessageUuid, peerUuidThe sender of a file or voice note this installation was downloading can no longer send it: the file is gone or changed, or the message was deleted. It comes with the Failed state change; retry_file_transfer refuses that download from then on.
fileTransferRecordRemovedmessageUuid, peerUuid, directionA transfer was canceled, on either side, and left the live lists. Its record stays with the state Canceled, and get_file_transfer still returns it.

Groups

EventDataWhat happened
groupUpdatedgroupIdSomething about that group changed. Read it again with get_group; the event does not carry the new value.
groupInvitationReceivedchatId, messageUuid, inviterId, groupUuid, groupName, memberCount, invitationId, expiresAt, textSomeone invited you to a group. Answer with answer_group_invitation, passing these fields back. expiresAt is 0 when the invitation does not expire.
groupInvitationAnsweredchatId, messageUuid, fromUserId, groupUuid, groupId, invitationId, answer, outcomeAn answer to an invitation arrived and was acted on. answer is accept, decline or noLongerValid; outcome is joined, alreadyMember, declined, noLongerValid or refused. groupId is 0 when the group is not held here.
groupJoinedgroupId, groupUuid, nameThis installation joined a group, or was added to it again, because of an invitation it accepted.
groupRulesAppliedgroupId, invitedIds, removedIdsA group's own rules, kept by this installation as one of its admins, invited some users (a BeeBEEP 5.x user is added) or removed members not seen for the rule's days. Sent only when the rules did something.

Plugins

EventDataWhat happened
pluginInviteReceivedchatId, messageUuid, inviterId, sessionId, pluginId, pluginVersion, pluginName, modeId, modeName, storeUrl, seats, expiresAt, autoAnswerSomeone invited you to a plugin session. autoAnswer is busy or unavailable when BeeBEEP answered by itself and empty when the user is asked; answer with answer_plugin_invite.
pluginInviteAnsweredsessionId, userId, userUuid, stateAn invitation you sent changed state: accepted, declined, busy, unavailable, expired or replaced. userId is null when the user is not known.
pluginSessionStartedthe fields of a session recordA plugin session runs here: it started, was adopted when its inviter started it, or was resumed. The fields are those of one entry of list_plugin_sessions.
pluginSessionSuspendedsessionIdA session was put aside on this side.
catalogueReadoutcomeA read of the catalogue of Mini Apps ended: accepted, unreachable, untrusted or off.
catalogueInstalledid, status, version, messageinstall_from_catalogue ended for the entry id.
pluginDataReceivedsessionId, fromId, fromUuid, sequence, byteCount, text, bytesBase64, bytesOmittedA plugin session received bytes. Up to 4 KiB they come with the event: bytesBase64 always, text too when they are valid UTF-8. Larger ones, such as a shared screen's frames, come as byteCount alone, with bytesOmitted true. fromId is null when the sender is not known.
pluginDataWaitingsessionId, fromUuidData arrived for a session known here but not running, one that waits for its start or is suspended. The sender keeps it.
pluginDeliveryFailedsessionId, sequenceA send with a deadline reached it without an acknowledgement.
pluginParticipantChangedsessionId, userId, userUuid, onlineA participant of an active session came online or went away. userId is null when the user is not known.
pluginSessionEndedsessionId, reasonA session ended, here, by the other side, or because an invitation came to nothing. reason is ended, declined, busy, unavailable, expired, error or none.
liveChannelPathChangedsessionId, userUuid, pathThe way a live session's frames reach a participant changed. path is none, probing, udp or tcp.

Networks

EventDataWhat happened
dialGaveUpaddressA connection asked for by hand, with connect_to_address or in the app, failed through all its retries and is no longer retried by itself. connect_to_address dials it again at once.
hostNotFoundhostA host name asked for by hand resolved to no address worth dialing, so nothing was dialed.
dialRefusedaddressA connection asked for by hand was not made, because the administrator keeps BeeBEEP to a list of computers and that address is not on it. address is ip:port.
unclassifiedNetworkJoinednetworkId, nameA network nobody has classified yet was joined: the moment to ask the user and call set_network_category.
networkCategoryChangednetworkId, previousCategory, categoryA network's category changed, through set_network_category or, on Windows, by the operating system.
networkPromotionsRevocablenetworkId, userCountA network stopped being private while userCount users it made contacts are still contacts. Nobody was demoted; revert_network_promotions does it.
searchCompletednoneThe search started by search_users ended, and any Bluetooth or multicast search it started has stopped.
firewallVerdictChangedfirewallThe firewall's verdict on this program's incoming connections changed. firewall is the word status reports: open, allowed, blocked, promptComes, thirdParty, policy or empty when nothing is read.

The program and the computer

EventDataWhat happened
circlesChangedcircles, circlesLockedYour circles changed, through set_circles, the app or the administrator's policy file. The fields are those of get_circles.
clockStateChangedlooksWrong, violatedFloor, systemClock, floorValueThe verdict on the computer's clock changed, which is rare: at start when there is something to say, after a jump of the clock, after set_clock_time or confirm_system_clock. The fields are those of clock_status.
dataFolderUnwritablefolderThe data folder checked at start cannot be written, so nothing can be saved while it lasts.
dataFolderWritableAgainfolderA later start found the data folder writable again.
settingsFileUnwritablefileThe settings file is read-only in a folder that can be written: a changed setting lasts only until BeeBEEP ends.
settingsFileWritableAgainfileThe settings file can be written again.
lowDiskSpacenoneThe disk is too full: the database keeps what it should write in memory.
diskSpaceRecoverednoneWrites go to disk again and what was held in memory is saved.
guiStalldurationMs, endedAtMsBeeBEEP's window answers again after it stopped answering for longer than guiStallWarnMsecs: durationMs is how long, endedAtMs when it ended, in milliseconds since 1970. Messages and the console went on meanwhile.
sessionActivityChangedactive, reasonOn a Linux desktop only: the session was locked, put under a screen saver or behind another session (active false: BeeBEEP stops drawing its windows, messages go on), or is back (active true). reason names what decided: sessionInactive, locked, lockRequested or screenSaver on the way away; sessionActive, unlocked, unlockRequested, screenSaverOff or lockUnconfirmed on the way back.
newerVersionAvailableversion, pageA newer BeeBEEP is out: version is its number, page where to get it. Said once per version in a run.

The console itself

EventDataWhat happened
consoleClosingreason, codeThe farewell, the last line before the console closes the connection. code is switchedOff (the person switched the console off in Settings) or quitting (BeeBEEP is shutting down); reason is its English text. It reaches every authenticated connection, whatever it subscribed to.

Tutte le pagine della guida