UnityLaparoscopicSceneSimul.../Assets/Scripts/VideoChat/VideoChatMediaStreamService.cs
2026-03-18 20:09:32 +03:00

35 lines
811 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WebSocketSharp;
using WebSocketSharp.Server;
public class VideoChatMediaStreamService : WebSocketBehavior
{
private static List<string> connections = new ()
{
//"01", "02", "10", "12", "20", "21"
"01", "10"
};
private static int connectionsCounter = 0;
protected override void OnOpen()
{
Sessions.SendTo(connectionsCounter.ToString(), ID);
connectionsCounter++;
Sessions.SendTo(string.Join('|', connections), ID);
}
protected override void OnMessage(MessageEventArgs e)
{
foreach (var id in Sessions.ActiveIDs)
{
if (id != ID)
{
Sessions.SendTo(e.Data, id);
}
}
}
}