Skip to content

Comments

WebRTC: add implementation of ChatSessionRequest capability to start IM fix#146

Open
Misterblue wants to merge 3 commits intoOpenSim-NGC:developfrom
Herbal3d:bug/Webrtc-IM-1
Open

WebRTC: add implementation of ChatSessionRequest capability to start IM fix#146
Misterblue wants to merge 3 commits intoOpenSim-NGC:developfrom
Herbal3d:bug/Webrtc-IM-1

Conversation

@Misterblue
Copy link

Add implementation of the ChatSessionRequest capability which enables IMs while using the webrtc voice module. This is an initial solution as there are other functions of the capability that are not yet implemented.

Copilot AI review requested due to automatic review settings February 15, 2026 00:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds implementation of the ChatSessionRequest capability to the WebRTC voice module to enable instant messaging functionality. The implementation handles P2P voice session start requests and other related methods, addressing an issue where IMs were not working while using the WebRTC voice module. The PR also includes code refactoring to extract common LLSD parsing logic into a reusable helper method.

Changes:

  • Added ChatSessionRequest capability handler for P2P voice session initialization
  • Extracted duplicate LLSD request body parsing logic into a reusable BodyToMap helper method
  • Updated documentation comments to use proper XML doc format

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
addon-modules/os-webrtc-janus/WebRtcVoiceRegionModule/WebRtcVoiceRegionModule.cs Main implementation: registers ChatSessionRequest capability, adds handler method with switch-case for different request types, extracts BodyToMap helper, includes various formatting fixes
addon-modules/os-webrtc-janus/WebRtcVoice/VoiceViewerSession.cs Code formatting improvements (whitespace cleanup, property formatting)
addon-modules/os-webrtc-janus/WebRtcVoice/IWebRtcVoiceService.cs Converts comment to XML documentation format
addon-modules/os-webrtc-janus/WebRtcVoice/IVoiceViewerSession.cs Adds XML documentation comment
addon-modules/os-webrtc-janus/VERSION Version bump from 2.1.1 to 2.1.2

Comment on lines +553 to +565
private OSDMap BodyToMap(IOSHttpRequest request, string pCaller)
{
OSDMap? map = null;
using (Stream inputStream = request.InputStream)
{
if (inputStream.Length > 0)
{
OSD tmp = OSDParser.DeserializeLLSDXml(inputStream);
if (_MessageDetails) m_log.DebugFormat("{0} BodyToMap: Request: {1}", pCaller, tmp.ToString());
map = tmp as OSDMap;
}
}
return map;
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BodyToMap helper method returns a nullable OSDMap (OSDMap?), but the calling code checks using "is null" which is appropriate. However, there's an inconsistency in error handling - when the request body is empty or invalid, this method returns null and the caller returns NotFound (404). Consider whether BadRequest (400) would be more appropriate for invalid/empty request bodies, as NotFound typically indicates a missing resource rather than a malformed request.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two of the routines return HttpStatusCode.NoContent so the one request that returns NotFound would be better to return HttpStatusCode.NoContent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made in subsequent commits

Comment on lines 341 to 347
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}

if (!reqmap.TryGetUUID("session-id", out UUID sessionID))
{
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error logging when request validation fails. When method or session-id are missing from the request (lines 340-350), the handler returns NotFound without logging any diagnostic information. This makes debugging client integration issues difficult. Consider adding debug or warning log messages similar to line 318 to help diagnose why requests are being rejected.

Suggested change
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
if (!reqmap.TryGetUUID("session-id", out UUID sessionID))
{
{
m_log.Warn($"[WebRTC] ChatSessionRequest: missing required 'method' field in request for agent {agentID}");
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
if (!reqmap.TryGetUUID("session-id", out UUID sessionID))
{
m_log.Warn($"[WebRTC] ChatSessionRequest: missing required 'session-id' field in request for agent {agentID}");

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes made in subsequent commits

return;
}

m_log.Debug($"[WebRTC] ChatSessionRequest");
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 338 uses the generic "WebRTC" prefix instead of the more specific logHeader variable used elsewhere in the file. For consistency with the rest of the module's logging (e.g., lines 318, 412-414), this should use the logHeader variable and include the method context like other log statements in this file.

Suggested change
m_log.Debug($"[WebRTC] ChatSessionRequest");
m_log.DebugFormat("{0}: ChatSessionRequest", logHeader);

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in subsequent commits.

Comment on lines 372 to 381
queue.ChatterBoxSessionStartReply(
newSessionID,
OSD.FromString(sp.Name),
2,
false,
true,
sessionID,
true,
string.Empty,
agentID);
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IEventQueue interface returned from RequestModuleInterface can be null if the EventQueue module is not loaded or available. Calling queue.ChatterBoxSessionStartReply without checking for null could result in a NullReferenceException. Add a null check before using the queue object, similar to how other parts of the codebase handle this pattern (e.g., using the null-conditional operator or an explicit null check with early return).

Suggested change
queue.ChatterBoxSessionStartReply(
newSessionID,
OSD.FromString(sp.Name),
2,
false,
true,
sessionID,
true,
string.Empty,
agentID);
if (queue != null)
{
queue.ChatterBoxSessionStartReply(
newSessionID,
OSD.FromString(sp.Name),
2,
false,
true,
sessionID,
true,
string.Empty,
agentID);
}
else
{
m_log.WarnFormat("{0}: EventQueue module not available; unable to send ChatterBoxSessionStartReply for agent {1} in scene {2}", logHeader, agentID, scene.RegionInfo.RegionName);
}

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in subsequent commits

IEventQueue queue = scene.RequestModuleInterface<IEventQueue>();
queue.ChatterBoxSessionStartReply(
newSessionID,
OSD.FromString(sp.Name),
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second parameter to ChatterBoxSessionStartReply should be a string (sessionName), but OSD.FromString(sp.Name) is being passed. This is incorrect - OSD.FromString returns an OSD object, not a string. Simply pass sp.Name directly as the sessionName parameter instead of wrapping it with OSD.FromString.

Suggested change
OSD.FromString(sp.Name),
sp.Name,

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in subsequent commits

…nRequest.

Correct parameters sent to ChatterBoxSessionStartReply.
Return consistant error codes when request bodies are empty/unparsable.
…parsing.

Check for null error if RequestModuleInterface<IEventQueue> fails (neven happens).
@mdickson mdickson changed the base branch from master to develop February 22, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant