<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnDatabaseConnectionStateChange</id>
	<title>OnDatabaseConnectionStateChange - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnDatabaseConnectionStateChange"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnDatabaseConnectionStateChange&amp;action=history"/>
	<updated>2026-09-19T13:10:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=OnDatabaseConnectionStateChange&amp;diff=892&amp;oldid=prev</id>
		<title>QCherry: Document upcoming 0.1.4 database recovery; organize wiki navigation</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnDatabaseConnectionStateChange&amp;diff=892&amp;oldid=prev"/>
		<updated>2026-09-19T10:51:46Z</updated>

		<summary type="html">&lt;p&gt;Document upcoming 0.1.4 database recovery; organize wiki navigation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= onDatabaseConnectionStateChange =&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Available since 0.1.4 (in development; not present in public 0.1.3). Server-side event.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Callback ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function(connection, state, generation, errorCode, errorMessage)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delivered on the owning resource&amp;#039;s Lua tick, including the initial connected transition. connection compares equal to the handle returned by dbConnect. State transitions include connected, reconnecting, disconnected and transaction_lost. The event is not broadcast to other resources or clients. Source is the owning resource root. Explicit close/shutdown does not promise a final event.&lt;br /&gt;
&lt;br /&gt;
Each generation identifies a different native database session. Error details describe the transition; repeated retries in the same state need not produce additional events. Up to 256 state notifications are retained per resource, dropping oldest entries on overflow. Events describe history; [[dbGetConnectionState]] returns the latest snapshot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onDatabaseConnectionStateChange&amp;quot;, resourceRoot,&lt;br /&gt;
    function(connection, state, generation, errorCode, errorMessage)&lt;br /&gt;
        if connection ~= db then return end&lt;br /&gt;
        outputDebugString(&amp;quot;DB &amp;quot; .. state .. &amp;quot;, generation=&amp;quot; .. generation)&lt;br /&gt;
    end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do not infer that a lost COMMIT failed. Do not blindly replay failed writes. See [[MySQL connection recovery]].&lt;br /&gt;
[[Category:Lua Events]]&lt;br /&gt;
[[Category:Server Events]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>