Browse Source

Voice integration somewhat works but need a lot more fine tuning

Ticket #1113 @1h30m
bugfix/1132
Martin Bober 3 years ago
parent
commit
2c5d13e39e
  1. 4
      app/assets/javascripts/gm_screen/gm_screen.coffee
  2. 4
      app/assets/javascripts/gm_screen/live_composer.coffee
  3. 77
      app/assets/javascripts/gm_screen/mumble_composer.coffee
  4. 4
      app/assets/javascripts/gm_screen/player_screen.coffee
  5. 1
      app/views/gm_screens/show.html.erb
  6. 5
      app/views/layouts/_header.html.erb
  7. 2
      app/views/player_screens/show.html.erb
  8. 6
      docker-compose.yml
  9. 61533
      public/5a0b29f05dcd52d0f258.worker.js
  10. 9126
      public/9bb692c4f612e63089c9.worker.js
  11. 57437
      public/charxchange_mumble.js
  12. 9068
      public/d790a5dd1d1c3076d3c7.worker.js

4
app/assets/javascripts/gm_screen/gm_screen.coffee

@ -1,4 +1,4 @@
#= require './live_composer'
#= require './mumble_composer'
#= require './panel'
#= require './dice_bot'
#= require './line_break'
@ -11,7 +11,7 @@
#= require './session_log_display'
#= require './sketch_panel'
@GmScreen = class GmScreen extends LiveComposer
@GmScreen = class GmScreen extends MumbleComposer
TAG_NAME_NSC_LIST = 'nsclist'
TAG_NAME_CHARACTER = 'character'

4
app/assets/javascripts/gm_screen/live_composer.coffee

@ -37,7 +37,7 @@
onSessionsReceived: (sessionsStatus) ->
sesId = null
sesName = null
sesName = undefined
for sess in sessionsStatus
if sess['campaign_id'] == @options['campaignId']
sesId = sess['session_id']
@ -52,7 +52,7 @@
else
@issueNotification('success', document.createTextNode(t(I18n['gmscreen']['live_connect'], {name: sesName})))
for listener in @liveConnectionListeners
listener[callback](sesId)
listener[callback](sesId, sesName)
@startLiveSessionTimer()
onGetSessionsError: (err) ->

77
app/assets/javascripts/gm_screen/mumble_composer.coffee

@ -0,0 +1,77 @@
#= require './live_composer'
#= require '../utils'
@MumbleComposer = class MumbleComposer extends LiveComposer
constructor: (container, options) ->
super(container, options)
@addLiveConnectionListener(@)
@widget = document.getElementById('navbar-widget')
clearChildren(@widget)
@mumbleOptions = {
url: window.MUMBLE_URL
user_name: "Foo"
}
self = @
@mumbleListener = {
onStatusChanged: (newStatus) ->
if (newStatus == "ERROR") or (newStatus == "DISCONNECTED")
self.onLiveSessionDisconnect()
else if newStatus == "CONNECTED"
self.setConnectedState()
setTimeout((() ->
for id, ch of self.mumbleConnection._client.channels
if ch.name == self.mumbleOptions['channel_name']
self.mumbleConnection._client.self.setChannel(ch)
return
console.error "Channel #{self.mumbleOptions['channel_name']} not found."
), 250)
else
self.setProgressState()
}
# Got session info from dicebot
onLiveSessionConnect: (sessionId, channelName) ->
@mumbleOptions['comment'] = ''
@mumbleOptions['channel_name'] = channelName
@mumbleConnection = new window.charXchangeMumnble.MumbleSession.getSession(@mumbleOptions, @mumbleListener)
@setDisconnectedState()
# Session has ended according to dicebot
onLiveSessionDisconnect: () ->
# TODO
setDisconnectedState: () ->
self = @
clearChildren(@widget)
connectBtn = createHtmlElement('button', {}, "Connect")
connectBtn.addEventListener('click', (event) ->
event.preventDefault()
self.setProgressState()
self.mumbleConnection.voiceInit()
setTimeout((() -> self.mumbleConnection.connect()), 5000)
)
@widget.appendChild(connectBtn)
setProgressState: () ->
clearChildren(@widget)
prog = createHtmlElement('div', {class: 'progress'})
bar = createHtmlElement('div', {
class: 'progress-bar progress-bar-striped active'
role: 'progressbar'
'aria-valuenow': '100',
'aria-valuemin': '0',
'aria-valuemax': '100',
style: 'width: 100%'
})
prog.appendChild(bar)
@widget.appendChild(prog)
setConnectedState: () ->
clearChildren(@widget)
disconBtn = createHtmlElement('button', {}, "Disconnect")
disconBtn.addEventListener('click', (event) ->
event.preventDefault()
# TOD
)
@widget.appendChild(disconBtn)

4
app/assets/javascripts/gm_screen/player_screen.coffee

@ -1,4 +1,4 @@
#= require './live_composer'
#= require './mumble_composer'
#= require './notes'
#= require './line_break'
#= require './dice_bot_player'
@ -8,7 +8,7 @@
#= require './pc_editor'
#= require '../utils'
@PlayerScreen = class PlayerScreen extends LiveComposer
@PlayerScreen = class PlayerScreen extends MumbleComposer
constructor: (container, rpgSystem = null) ->
super(container, {

1
app/views/gm_screens/show.html.erb

@ -32,6 +32,7 @@
<div id="notifications_container" style="position: fixed; bottom: 0; left: 20px"></div>
<script src="/charxchange_mumble.js"></script>
<!--suppress JSDuplicatedDeclaration, JSUnusedLocalSymbols -->
<script>

5
app/views/layouts/_header.html.erb

@ -9,6 +9,7 @@
</button>
<%= link_to 'charXchange', root_path, class: 'navbar-brand' %>
</div>
<form id="navbar-widget" class="navbar-form navbar-left"></form>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
@ -234,6 +235,7 @@
}
window["currentPlayer"] = null;
window.open_graph_proxy_url = "<%= ENV['OPEN_GRAPH_PROXY_URL']%>";
window.MUMBLE_URL = "<%= ENV['MUMBLE_URL']%>";
</script>
<% if logged_in?%>
@ -247,7 +249,8 @@
new MessageDisplay();
window["currentPlayer"] = {
name: "<%= current_player.name %>",
id: <%= current_player.id %>
id: <%= current_player.id %>,
avatar_url: "<%= current_player.avatar %>"
};
</script>
<% end %>

2
app/views/player_screens/show.html.erb

@ -32,7 +32,7 @@
<div id="notifications_container" style="position: fixed; bottom: 0; left: 20px"></div>
<script src="/charxchange_mumble.js"></script>
<!--suppress JSDuplicatedDeclaration, JSUnusedLocalSymbols -->
<script>
$(document).ready(function () {

6
docker-compose.yml

@ -84,8 +84,7 @@ services:
SECRET_KEY_BASE: '894b26dfa5417b3fa1c0c30bbb7be0bd32539d533fa16b690b53d15b0ddd5b0b3c37ffb1ce99e77a4c00c28d0a961e6414b5d09814feecb17cc6ffdbaa7652a9'
DICEBOT_URL: "http://localhost:8100"
OPEN_GRAPH_PROXY_URL: "http://localhost:8101"
MUMBLE_ADDRESS: "localhost"
MUMBLE_WEBSOCK_PORT: 64737
MUMBLE_URL: "ws://localhost:64737"
volumes:
- production_paperclip_data:/usr/src/app/public/system
@ -125,8 +124,7 @@ services:
DICEBOT_URL_INTERNAL: "http://dicebot:8080"
DICEBOT_SECRET: "FOOBAR"
OPEN_GRAPH_PROXY_URL: "http://localhost:8101"
MUMBLE_ADDRESS: "localhost"
MUMBLE_WEBSOCK_PORT: 64737
MUMBLE_URL: "ws://localhost:64737"
volumes:
- ".:/usr/src/app"
- development_paperclip_data:/usr/src/app/public/system

61533
public/5a0b29f05dcd52d0f258.worker.js

File diff suppressed because one or more lines are too long

9126
public/9bb692c4f612e63089c9.worker.js

File diff suppressed because one or more lines are too long

57437
public/charxchange_mumble.js

File diff suppressed because one or more lines are too long

9068
public/d790a5dd1d1c3076d3c7.worker.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save