Skip to content

Commit

Permalink
Add method to allow simulation of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Jan 29, 2023
1 parent 66b7714 commit e248991
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/client/pages/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import { sendEvent } from 'lib/socket'

export default function TestPage () {
return (
<>
<div style={{padding: '1rem'}}>
<h1>Test Page</h1>
</>
<hr/>
<h2>Simulate Events</h2>
<p>
Send a test event to all connected clients.
</p>
<input id='debug_event_name' defaultValue='Test' style={{textTransform: 'none'}}/>
<p>
<button onClick={() => {
sendEvent('testMessage', { name: document.getElementById('debug_event_name').value })
}}>Send Event</button>
</p>
<h2>Simulate Log Entry</h2>
<p>
Simulate an event triggered after an in-game log entry is fired.
</p>
<input id='debug_log_entry_name' defaultValue='Scan' style={{textTransform: 'none'}}/>
<p>
<button onClick={() => {
sendEvent('testMessage', {
name: 'newLogEntry',
message: {
event: document.getElementById('debug_log_entry_name').value }
}
)
}}>Simulate Log Entry</button>
</p>
</div>
)
}
5 changes: 5 additions & 0 deletions src/service/lib/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class EventHandlers {
// return null
// }
// },
testMessage: ({name, message}) => {
console.log('sending test message', name)
// Method to simulate messages, intended for developers
if (name !== 'testMessage') broadcastEvent(name, message)
},
testVoice: ({ voice }) => {
// Escape voice name when passing as text as precaution to clean
// input (NB: voice name argument is checked internally)
Expand Down

0 comments on commit e248991

Please sign in to comment.