public void SendAnswer(string connectionId, RTCSessionDescription answer) { DescData data = new DescData(); data.connectionId = connectionId; data.sdp = answer.sdp; data.type = "answer"; RoutedMessage <DescData> routedMessage = new RoutedMessage <DescData>(); routedMessage.to = connectionId; routedMessage.data = data; routedMessage.type = "answer"; WSSend(routedMessage); }
public void SendOffer(string connectionId, RTCSessionDescription offer) { DescData data = new DescData(); data.connectionId = connectionId; data.sdp = offer.sdp; data.type = "offer"; RoutedMessage <DescData> routedMessage = new RoutedMessage <DescData>(); routedMessage.from = connectionId; routedMessage.data = data; routedMessage.type = "offer"; Send(routedMessage); }
public void SendCandidate(string connectionId, RTCIceCandidate candidate) { CandidateData data = new CandidateData(); data.connectionId = connectionId; data.candidate = candidate.candidate; data.sdpMLineIndex = candidate.sdpMLineIndex; data.sdpMid = candidate.sdpMid; RoutedMessage <CandidateData> routedMessage = new RoutedMessage <CandidateData>(); routedMessage.to = connectionId; routedMessage.data = data; routedMessage.type = "candidate"; WSSend(routedMessage); }
public void SendCandidate(string connectionId, RTCIceCandidate candidate) { CandidateData data = new CandidateData(); data.connectionId = connectionId; data.candidate = candidate.Candidate; data.sdpMLineIndex = candidate.SdpMLineIndex.GetValueOrDefault(0); data.sdpMid = candidate.SdpMid; RoutedMessage <CandidateData> routedMessage = new RoutedMessage <CandidateData>(); routedMessage.from = connectionId; routedMessage.data = data; routedMessage.type = "candidate"; Send(routedMessage); }
/// <summary> /// Forwards a message to the appropriate slave /// </summary> /// <param name="parameters"></param> /// <param name="session"></param> /// <param name="messageToRoute"></param> /// <param name="cancellationToken"></param> /// <returns></returns> async Task <dynamic> _routeMessage(dynamic parameters, PlayerSession session, RoutedMessage messageToRoute, CancellationToken cancellationToken) { var routingType = messageToRoute.MessageContainer.RoutingData.TargetIdType; var routingId = messageToRoute.MessageContainer.RoutingData.TargetId; var msg = messageToRoute.MessageContainer; int destinationChannelId = 0; switch (routingType) { case MessageRoutingIdTypes.AreaId: { var areaModel = await _databaseManager.GetAreaAsync(routingId); if (areaModel == null) { return("AreaId not found while attempting admin message route."); } break; } case MessageRoutingIdTypes.PlayerId: { var playerModel = await _databaseManager.GetPlayerAsync(routingId); if (playerModel == null) { return("PlayerId not found while attempting admin message route."); } else if (playerModel.CurrentAreaID == null) { return("Player.CurrentAreaID was null when attempting admin message route."); } destinationChannelId = playerModel.CurrentAreaID.Value; break; } case MessageRoutingIdTypes.ShipId: { var shipModel = await _databaseManager.GetShipAsync(routingId); if (shipModel == null) { return("ShipId not found while attempting admin message route."); } else if (shipModel.CurrentAreaID == null) { return("Ship.CurrentAreaID was null when attempting admin message route."); } destinationChannelId = shipModel.CurrentAreaID.Value; break; } } _redisServer.PublishObjectAsync(ChannelTypes.WebToSlave, destinationChannelId, msg); return("Success"); }