Added hermes websocket support. Added chat command support. Added selectable voice command via websocket. Added websocket heartbeat management.

This commit is contained in:
Tom
2024-03-15 12:27:35 +00:00
parent b5cc6b5706
commit d4004d6230
53 changed files with 1227 additions and 461 deletions

View File

@@ -21,15 +21,15 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
if (message is not EventMessage obj || obj == null)
return;
switch (obj.eventType) {
switch (obj.EventType) {
case "StreamStateChanged":
case "RecordStateChanged":
if (sender is not OBSSocketClient client)
return;
string? raw_state = obj.eventData["outputState"].ToString();
string? raw_state = obj.EventData["outputState"].ToString();
string? state = raw_state?.Substring(21).ToLower();
client.Live = obj.eventData["outputActive"].ToString() == "True";
client.Live = obj.EventData["outputActive"].ToString() == "True";
Logger.LogWarning("Stream " + (state != null && state.EndsWith("ing") ? "is " : "has ") + state + ".");
if (client.Live == false && state != null && !state.EndsWith("ing")) {
@@ -37,7 +37,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
}
break;
default:
Logger.LogDebug(obj.eventType + " EVENT: " + string.Join(" | ", obj.eventData?.Select(x => x.Key + "=" + x.Value?.ToString()) ?? new string[0]));
Logger.LogDebug(obj.EventType + " EVENT: " + string.Join(" | ", obj.EventData?.Select(x => x.Key + "=" + x.Value?.ToString()) ?? new string[0]));
break;
}
}

View File

@@ -25,15 +25,14 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
return;
Logger.LogTrace("OBS websocket password: " + Context.Password);
if (obj.authentication is null || Context.Password is null) // TODO: send re-identify message.
if (obj.Authentication == null || Context.Password == null) // TODO: send re-identify message.
return;
var salt = obj.authentication.salt;
var challenge = obj.authentication.challenge;
var salt = obj.Authentication.Salt;
var challenge = obj.Authentication.Challenge;
Logger.LogTrace("Salt: " + salt);
Logger.LogTrace("Challenge: " + challenge);
string secret = Context.Password + salt;
byte[] bytes = Encoding.UTF8.GetBytes(secret);
string hash = null;
@@ -48,8 +47,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
}
Logger.LogTrace("Final hash: " + hash);
//await sender.Send(1, new IdentifyMessage(obj.rpcVersion, hash, 1023 | 262144 | 524288));
await sender.Send(1, new IdentifyMessage(obj.rpcVersion, hash, 1023 | 262144));
await sender.Send(1, new IdentifyMessage(obj.RpcVersion, hash, 1023 | 262144));
}
}
}

View File

@@ -20,7 +20,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
return;
sender.Connected = true;
Logger.LogInformation("Connected to OBS via rpc version " + obj.negotiatedRpcVersion + ".");
Logger.LogInformation("Connected to OBS via rpc version " + obj.NegotiatedRpcVersion + ".");
}
}
}

View File

@@ -19,13 +19,13 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
if (message is not RequestResponseMessage obj || obj == null)
return;
switch (obj.requestType) {
switch (obj.RequestType) {
case "GetOutputStatus":
if (sender is not OBSSocketClient client)
return;
if (obj.requestId == "stream") {
client.Live = obj.responseData["outputActive"].ToString() == "True";
if (obj.RequestId == "stream") {
client.Live = obj.ResponseData["outputActive"].ToString() == "True";
Logger.LogWarning("Updated stream's live status to " + client.Live);
}
break;