Push Events
Sonoran CAD pushes event data to your community for further integration possibilities. Learn more below!
All push events require the Plus version of Sonoran CAD or higher. For more information, see our pricing page.
Looking for VPS, web, or dedicated hosting? Check out our official server hosting!

Configuring your Listener

1. Admin Panel Configuration

In the admin panel, navigate to: Advanced > In-Game Integration Expand the "Server Events and Integrated Live Map" section.
Enter your server's public IP address and your game server's port. Sonoran CAD will send events to http://ip:gameport/sonorancad/event utilizing your existing game port.
Push event configuration is covered as a part of the framework installation.

Developer Documentation

Many of our integration plugins rely on these push events for full functionality. Interested in developing your own plugins? Expand the push event and API endpoint documentation in the left side drawer.

Web Server Example

Javascript

You can create your own web server to listen and receive Sonoran CAD events. This could be on a Discord bot, an in-game script, etc.
In addition, you may already be receiving these events in your integration framework. The integration framework can be configured to "forward" all push events received to another custom webserver, like the example shown below. Simply set enablePushEventForwarding to true and pushEventForwardUrl to your webserver's http://IP:Port.
1
// ----------------------------
2
// Webserver Handling
3
// Description: Create web server and listen to CAD push events locally
4
// ----------------------------
5
6
// Use the JS HTTP library to create a new webserver
7
// Pass any traffic to the 'handler' function
8
let server = require('http').createServer(handler);
9
10
// Sonoran CAD community API key
11
// Used to authenticate traffic received
12
const API_KEY = "YOUR_API_KEY";
13
14
// Start the webserver on a specific port
15
// Ensure you have this port OPEN on your external IP
16
// https://portchecker.co/
17
let port = 30150;
18
server.listen(port);
19
20
// Webserver traffic handler
21
async function handler (req, res) {
22
let data = ''; // Parsed JSON data
23
let success = false; // Successful parsing/handling
24
let responseMessage = ""; // Response text back to server
25
26
// Only handle POST requests
27
// Only handle requests sent to /sonorancad/event (CAD push events)
28
if (req.method === "POST" && req.url === '/sonorancad/event') {
29
req.on('data', function(chunk) {
30
// Read and piece each part of data together
31
data += chunk;
32
});
33
34
// Once we've fully read the request
35
req.on('end', async function() {
36
// Parse data string to a local JSON object
37
data = JSON.parse(data);
38
39
// Authenticate data
40
// Sonoran CAD sends your API KEY with the POST data
41
// Check this here to prevent someone random sending you requests
42
if (data.key === API_KEY) {
43
// Switch Case: handle each event type
44
switch (data.type) {
45
case "EVENT_911":
46
// New 911 call placed
47
// Format: https://info.sonorancad.com/sonoran-cad/api-integration/push-events/event-911
48
console.log(`New 911 from ${data.caller}`);
49
break;
50
default:
51
// Push event type isn't handled here
52
responseMessage = "Invalid Type";
53
success = false;
54
sendResponse(success);
55
break;
56
}
57
} else {
58
// Server traffic didn't have the proper API key
59
responseMessage = "Authentication Key Failed!";
60
success = false;
61
sendResponse(success);
62
}
63
});
64
}
65
66
// Send response back to server
67
function sendResponse(success) {
68
// Return an HTTP 200 or 400 based on `success` boolean
69
const statusCode = success ? 200 : 400;
70
// Set response headers
71
res.writeHead(statusCode, {'Content-Type': 'text/plain'});
72
// Return response
73
res.end(responseMessage);
74
}
75
}
Copied!