59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using Agora.Rtc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Prism.Ioc;
|
|
using Prism.Events;
|
|
using Demo.Common.Events;
|
|
using Masuit.Tools;
|
|
|
|
namespace Demo.Common.Helpers
|
|
{
|
|
public class RtcEngineEventHandler : IRtcEngineEventHandler
|
|
{
|
|
private readonly IEventAggregator aggregator;
|
|
public RtcEngineEventHandler()
|
|
{
|
|
aggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
|
}
|
|
|
|
public override void OnUserJoined(RtcConnection connection, uint remoteUid, int elapsed)
|
|
{
|
|
//base.OnUserJoined(connection, remoteUid, elapsed);
|
|
Console.WriteLine($@"新用户加入: channelId:{connection.channelId} localuid: {connection.localUid} remoteuid:{remoteUid} elapsed: {elapsed}");
|
|
|
|
|
|
//var aggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
|
aggregator.GetEvent<UserJoinEvent>().Publish(new Models.User
|
|
{
|
|
Id = remoteUid,
|
|
UserName = remoteUid.ToString(),
|
|
IsManager = true,
|
|
IsLocal = false
|
|
});
|
|
}
|
|
|
|
|
|
public override void OnUserOffline(RtcConnection connection, uint remoteUid, USER_OFFLINE_REASON_TYPE reason)
|
|
{
|
|
//var aggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
|
aggregator.GetEvent<UserLeaveEvent>().Publish(new Models.User
|
|
{
|
|
Id = remoteUid,
|
|
UserName = remoteUid.ToString(),
|
|
IsManager = true,
|
|
IsLocal = false
|
|
});
|
|
}
|
|
|
|
public override void OnAudioVolumeIndication(RtcConnection connection, AudioVolumeInfo[] speakers, uint speakerNumber, int totalVolume)
|
|
{
|
|
|
|
//aggregator.GetEvent<AudioVolumeIndicationEvent>().Publish();
|
|
}
|
|
|
|
}
|
|
}
|