static void IncomingAVCallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> e) { ApplicationEndpoint applicationEndpoint = (ApplicationEndpoint)sender; bool callReplaced = false; if (e.CallToBeReplaced != null) { callReplaced = true; } Console.WriteLine("IncomingAVCallReceived for endpoint " + applicationEndpoint.OwnerUri + " RemoteEndpointUri=" + e.Call.RemoteEndpoint.Uri + " CallReplaced=" + callReplaced); if (!callReplaced) { Console.WriteLine("Incoming call from " + e.RemoteParticipant.UserAtHost + " received"); // Incoming call. Placing it into the random location Random rnd = new Random(); int index = rnd.Next(0, _locations.Count - 1); Console.WriteLine("Placing " + e.RemoteParticipant.UserAtHost + " to \"" + _locations[index].Name + "\""); // Place user to location UserCall userCall = new UserCall(e.RemoteParticipant.UserAtHost, e.Call, _locations[index]); userCall.Terminated += new EventHandler(userCall_Terminated); e.Call.ApplicationContext = userCall; _userCalls.Add(userCall); } else { // Transfer user to the next location // We are getting here after BeginTransfer was called foreach (UserCall userCall in _userCalls) { if (e.CallToBeReplaced.ApplicationContext == userCall) { int newLocationId = 0; if (userCall.TransferPath == UserCallTransferPath.Next) { newLocationId = userCall.Location.Id + 1; if (newLocationId >= _locations.Count) { newLocationId = 0; } } else if (userCall.TransferPath == UserCallTransferPath.Previous) { newLocationId = userCall.Location.Id - 1; if (newLocationId < 0) { newLocationId = _locations.Count - 1; } } e.Call.ApplicationContext = userCall; userCall.JoinLocation(e.Call, _locations[newLocationId]); break; } } } }
static void userCall_Terminated(object sender, EventArgs e) { UserCall userCall = (UserCall)sender; Console.WriteLine(userCall.Uri + " disconnected"); }
static void IncomingAVCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e) { ApplicationEndpoint applicationEndpoint = (ApplicationEndpoint)sender; bool callReplaced = false; if (e.CallToBeReplaced != null) { callReplaced = true; } Console.WriteLine("IncomingAVCallReceived for endpoint " + applicationEndpoint.OwnerUri + " RemoteEndpointUri=" + e.Call.RemoteEndpoint.Uri + " CallReplaced=" + callReplaced); if (!callReplaced) { Console.WriteLine("Incoming call from " + e.RemoteParticipant.UserAtHost + " received"); // Incoming call. Placing it into the random location Random rnd = new Random(); int index = rnd.Next(0, _locations.Count - 1); Console.WriteLine("Placing " + e.RemoteParticipant.UserAtHost + " to \"" + _locations[index].Name + "\""); // Place user to location UserCall userCall = new UserCall(e.RemoteParticipant.UserAtHost, e.Call, _locations[index]); userCall.Terminated += new EventHandler(userCall_Terminated); e.Call.ApplicationContext = userCall; _userCalls.Add(userCall); } else { // Transfer user to the next location // We are getting here after BeginTransfer was called foreach (UserCall userCall in _userCalls) { if (e.CallToBeReplaced.ApplicationContext == userCall) { int newLocationId = 0; if (userCall.TransferPath == UserCallTransferPath.Next) { newLocationId = userCall.Location.Id + 1; if (newLocationId >= _locations.Count) { newLocationId = 0; } } else if (userCall.TransferPath == UserCallTransferPath.Previous) { newLocationId = userCall.Location.Id - 1; if (newLocationId < 0) { newLocationId = _locations.Count - 1; } } e.Call.ApplicationContext = userCall; userCall.JoinLocation(e.Call, _locations[newLocationId]); break; } } } }