private void ProcessOnHold(HoldStatus status, Vector3 touchPosition) { if (OnHoldEvent != null) { OnHoldEvent(status, touchPosition); } }
public Hold(HoldStatus status, int index, string typeName, int x, int y) { this.status = status; this.index = index; type = (HandType)Enum.Parse(typeof(HandType), typeName); this.x = x; this.y = y; }
/// <summary> /// Retrieves holds for the supplied patron barcode as a staff member. /// </summary> /// <param name="barcode">The patron's barcode.</param> /// <param name="status">Status of the holds you wish to retrieve.</param> /// <returns>PatronHoldRequestsGetResult</returns> /// <seealso cref="PatronHoldRequestsGetResult"/> /// <seealso cref="HoldStatus"/> public PatronHoldRequestsGetResult Staff_PatronHoldRequestsGet(string barcode, HoldStatus status) { var request = new RestRequest(string.Format("public/v1/1033/100/1/patron/{0}/holdrequests/{1}", barcode, status.ToString())); request.AddUrlSegment("AccessToken", token.AccessToken); _client.Authenticator = new PolarisOverrideAuthenticator(ApiUser, ApiKey, token); return Execute<PatronHoldRequestsGetResult>(request); }
/// <summary> /// Event handler for receiving a re-INVITE request on an established call. /// In call requests can be used for multitude of different purposes. In this /// example program we're only concerned with re-INVITE requests being used /// to place a call on/off hold. /// </summary> /// <param name="uasTransaction">The user agent server invite transaction that /// was created for the request. It needs to be used for sending responses /// to ensure reliable delivery.</param> private static void ReinviteRequestReceived(UASInviteTransaction uasTransaction) { SIPRequest reinviteRequest = uasTransaction.TransactionRequest; // Re-INVITEs can also be changing the RTP end point. We can update this each time. IPEndPoint dstRtpEndPoint = SDP.GetSDPRTPEndPoint(reinviteRequest.Body); _remoteRtpEndPoint = dstRtpEndPoint; // If the RTP callfow attribute has changed it's most likely due to being placed on/off hold. SDP newSDP = SDP.ParseSDPDescription(reinviteRequest.Body); if (GetRTPStatusAttribute(newSDP) == RTP_ATTRIBUTE_SENDONLY) { Log.LogInformation("Remote call party has placed us on hold."); _holdStatus = HoldStatus.RemotePutOnHold; _ourSDP = GetSDP(_ourRtpSocket.LocalEndPoint as IPEndPoint, RTP_ATTRIBUTE_RECVONLY); var okResponse = SIPTransport.GetResponse(reinviteRequest, SIPResponseStatusCodesEnum.Ok, null); okResponse.Header.ContentType = SDP.SDP_MIME_CONTENTTYPE; okResponse.Body = _ourSDP.ToString(); uasTransaction.SendFinalResponse(okResponse); } else if (GetRTPStatusAttribute(newSDP) == RTP_ATTRIBUTE_SENDRECV && _holdStatus != HoldStatus.None) { Log.LogInformation("Remote call party has taken us off hold."); _holdStatus = HoldStatus.None; _ourSDP = GetSDP(_ourRtpSocket.LocalEndPoint as IPEndPoint, RTP_ATTRIBUTE_SENDRECV); var okResponse = SIPTransport.GetResponse(reinviteRequest, SIPResponseStatusCodesEnum.Ok, null); okResponse.Header.ContentType = SDP.SDP_MIME_CONTENTTYPE; okResponse.Body = _ourSDP.ToString(); uasTransaction.SendFinalResponse(okResponse); } else { Log.LogWarning("Not sure what the remote call party wants us to do..."); // We'll just reply Ok and hope eveything is good. var okResponse = SIPTransport.GetResponse(reinviteRequest, SIPResponseStatusCodesEnum.Ok, null); okResponse.Header.ContentType = SDP.SDP_MIME_CONTENTTYPE; okResponse.Body = _ourSDP.ToString(); uasTransaction.SendFinalResponse(okResponse); } }
private void OnHold(HoldStatus status, Vector3 position) { if (status == HoldStatus.Begin) { Vector3 viewportPosition = CameraManager.Instance.Main.ScreenToViewportPoint(position); if (viewportPosition.x >= 0.5) { m_currentAction = EInputAction.RightPressed; } else { m_currentAction = EInputAction.LeftPressed; } } else { m_currentAction = EInputAction.Idle; } }
/// <summary> /// Load from xml /// </summary> /// <param name="reader">The reader</param> /// <returns>Mailbox hold object</returns> internal static MailboxHoldResult LoadFromXml(EwsServiceXmlReader reader) { List <MailboxHoldStatus> statuses = new List <MailboxHoldStatus>(); reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.MailboxHoldResult); MailboxHoldResult holdResult = new MailboxHoldResult(); holdResult.HoldId = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.HoldId); // the query could be empty means there won't be Query element, hence needs to read and check // if the next element is not Query, then it means already read MailboxHoldStatuses element reader.Read(); holdResult.Query = string.Empty; if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Query)) { holdResult.Query = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Query); reader.ReadStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatuses); } do { reader.Read(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.MailboxHoldStatus)) { string mailbox = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Mailbox); HoldStatus status = (HoldStatus)Enum.Parse(typeof(HoldStatus), reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Status)); string additionalInfo = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.AdditionalInfo); statuses.Add(new MailboxHoldStatus(mailbox, status, additionalInfo)); } }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MailboxHoldResult)); holdResult.Statuses = statuses.Count == 0 ? null : statuses.ToArray(); return(holdResult); }
static void Main(string[] args) { Console.WriteLine("SIPSorcery call hold example."); Console.WriteLine("Press ctrl-c to exit."); // Plumbing code to facilitate a graceful exit. CancellationTokenSource exitCts = new CancellationTokenSource(); // Cancellation token to stop the SIP transport and RTP stream. bool isCallHungup = false; bool hasCallFailed = false; AddConsoleLogger(); // Check whether an override desination has been entered on the command line. SIPURI callUri = SIPURI.ParseSIPURI(DEFAULT_DESTINATION_SIP_URI); if (args != null && args.Length > 0) { if (!SIPURI.TryParse(args[0])) { Log.LogWarning($"Command line argument could not be parsed as a SIP URI {args[0]}"); } else { callUri = SIPURI.ParseSIPURIRelaxed(args[0]); } } Log.LogInformation($"Call destination {callUri}."); // Set up a default SIP transport. _sipTransport = new SIPTransport(); _sipTransport.AddSIPChannel(new SIPUDPChannel(new IPEndPoint(IPAddress.Any, 0))); EnableTraceLogs(_sipTransport); var lookupResult = SIPDNSManager.ResolveSIPService(callUri, false); Log.LogDebug($"DNS lookup result for {callUri}: {lookupResult?.GetSIPEndPoint()}."); var dstAddress = lookupResult.GetSIPEndPoint().Address; IPAddress localIPAddress = NetServices.GetLocalAddressForRemote(dstAddress); // Initialise an RTP session to receive the RTP packets from the remote SIP server. _ourRtpSocket = null; Socket controlSocket = null; NetServices.CreateRtpSocket(localIPAddress, 48000, 48100, false, out _ourRtpSocket, out controlSocket); var rtpRecvSession = new RTPSession((int)RTPPayloadTypesEnum.PCMU, null, null); var rtpSendSession = new RTPSession((int)RTPPayloadTypesEnum.PCMU, null, null); _ourSDP = GetSDP(_ourRtpSocket.LocalEndPoint as IPEndPoint, RTP_ATTRIBUTE_SENDRECV); // Create a client/server user agent to place a call to a remote SIP server along with event handlers for the different stages of the call. var userAgent = new SIPUserAgent(_sipTransport, null); userAgent.ClientCallTrying += (uac, resp) => { Log.LogInformation($"{uac.CallDescriptor.To} Trying: {resp.StatusCode} {resp.ReasonPhrase}."); }; userAgent.ClientCallRinging += (uac, resp) => Log.LogInformation($"{uac.CallDescriptor.To} Ringing: {resp.StatusCode} {resp.ReasonPhrase}."); userAgent.ClientCallFailed += (uac, err) => { Log.LogWarning($"{uac.CallDescriptor.To} Failed: {err}"); hasCallFailed = true; exitCts.Cancel(); }; userAgent.ClientCallAnswered += (uac, resp) => { if (resp.Status == SIPResponseStatusCodesEnum.Ok) { Log.LogInformation($"{uac.CallDescriptor.To} Answered: {resp.StatusCode} {resp.ReasonPhrase}."); // Only set the remote RTP end point if there hasn't already been a packet received on it. if (_remoteRtpEndPoint == null) { _remoteRtpEndPoint = SDP.GetSDPRTPEndPoint(resp.Body); Log.LogDebug($"Remote RTP socket {_remoteRtpEndPoint}."); } } else { Log.LogWarning($"{uac.CallDescriptor.To} Answered: {resp.StatusCode} {resp.ReasonPhrase}."); } }; userAgent.CallHungup += () => { Log.LogInformation($"Call hungup by remote party."); exitCts.Cancel(); }; userAgent.OnReinviteRequest += ReinviteRequestReceived; // The only incoming requests that need to be explicitly in this example program are in-dialog // re-INVITE requests that are being used to place the call on/off hold. _sipTransport.SIPTransportRequestReceived += (localSIPEndPoint, remoteEndPoint, sipRequest) => { try { if (sipRequest.Header.From != null && sipRequest.Header.From.FromTag != null && sipRequest.Header.To != null && sipRequest.Header.To.ToTag != null) { userAgent.InDialogRequestReceivedAsync(sipRequest).Wait(); } else if (sipRequest.Method == SIPMethodsEnum.OPTIONS) { SIPResponse optionsResponse = SIPTransport.GetResponse(sipRequest, SIPResponseStatusCodesEnum.Ok, null); _sipTransport.SendResponse(optionsResponse); } } catch (Exception excp) { Log.LogError($"Exception processing request. {excp.Message}"); } }; // It's a good idea to start the RTP receiving socket before the call request is sent. // A SIP server will generally start sending RTP as soon as it has processed the incoming call request and // being ready to receive will stop any ICMP error response being generated. Task.Run(() => RecvRtp(_ourRtpSocket, rtpRecvSession, exitCts)); Task.Run(() => SendRtp(_ourRtpSocket, rtpSendSession, exitCts)); // Start the thread that places the call. SIPCallDescriptor callDescriptor = new SIPCallDescriptor( SIP_USERNAME, SIP_PASSWORD, callUri.ToString(), $"sip:{SIP_USERNAME}@localhost", callUri.CanonicalAddress, null, null, null, SIPCallDirection.Out, SDP.SDP_MIME_CONTENTTYPE, _ourSDP.ToString(), null); userAgent.Call(callDescriptor); // At this point the call has been initiated and everything will be handled in an event handler. Task.Run(() => { try { while (!exitCts.Token.WaitHandle.WaitOne(0)) { var keyProps = Console.ReadKey(); if (keyProps.KeyChar == 'h') { // Place call on/off hold. if (userAgent.IsAnswered) { if (_holdStatus == HoldStatus.None) { Log.LogInformation("Placing the remote call party on hold."); _holdStatus = HoldStatus.WePutOnHold; _ourSDP = GetSDP(_ourRtpSocket.LocalEndPoint as IPEndPoint, RTP_ATTRIBUTE_SENDONLY); userAgent.SendReInviteRequest(_ourSDP); } else if (_holdStatus == HoldStatus.WePutOnHold) { Log.LogInformation("Removing the remote call party from hold."); _holdStatus = HoldStatus.None; _ourSDP = GetSDP(_ourRtpSocket.LocalEndPoint as IPEndPoint, RTP_ATTRIBUTE_SENDRECV); userAgent.SendReInviteRequest(_ourSDP); } else { Log.LogInformation("Sorry we're already on hold by the remote call party."); } } } else if (keyProps.KeyChar == 'q') { // Quit application. exitCts.Cancel(); } } } catch (Exception excp) { SIPSorcery.Sys.Log.Logger.LogError($"Exception Key Press listener. {excp.Message}."); } }); // Ctrl-c will gracefully exit the call at any point. Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; exitCts.Cancel(); }; // Wait for a signal saying the call failed, was cancelled with ctrl-c or completed. exitCts.Token.WaitHandle.WaitOne(); #region Cleanup. Log.LogInformation("Exiting..."); _ourRtpSocket?.Close(); controlSocket?.Close(); if (!isCallHungup && userAgent != null) { if (userAgent.IsAnswered) { Log.LogInformation($"Hanging up call to {userAgent?.CallDescriptor?.To}."); userAgent.Hangup(); } else if (!hasCallFailed) { Log.LogInformation($"Cancelling call to {userAgent?.CallDescriptor?.To}."); userAgent.Cancel(); } // Give the BYE or CANCEL request time to be transmitted. Log.LogInformation("Waiting 1s for call to clean up..."); Task.Delay(1000).Wait(); } SIPSorcery.Net.DNSManager.Stop(); if (_sipTransport != null) { Log.LogInformation("Shutting down SIP transport..."); _sipTransport.Shutdown(); } #endregion }
/// <summary> /// Constructor /// </summary> /// <param name="mailbox">Mailbox</param> /// <param name="status">Hold status</param> /// <param name="additionalInfo">Additional info</param> public MailboxHoldStatus(string mailbox, HoldStatus status, string additionalInfo) { Mailbox = mailbox; Status = status; AdditionalInfo = additionalInfo; }
/// <summary> /// Retrieves holds for the supplied patron barcode as a staff member. /// </summary> /// <param name="barcode">The patron's barcode.</param> /// <param name="status">Status of the holds you wish to retrieve.</param> /// <returns>PatronHoldRequestsGetResult</returns> /// <seealso cref="PatronHoldRequestsGetResult"/> /// <seealso cref="HoldStatus"/> public PatronHoldRequestsGetResult Staff_PatronHoldRequestsGet(string barcode, HoldStatus status) { var request = new RestRequest(string.Format("public/v1/1033/100/1/patron/{0}/holdrequests/{1}", barcode, status.ToString())); request.AddUrlSegment("AccessToken", token.AccessToken); _client.Authenticator = new PolarisOverrideAuthenticator(ApiUser, ApiKey, token); return(Execute <PatronHoldRequestsGetResult>(request)); }
private void OnHoldEvent(HoldStatus status, Vector3 position) { Debug.LogWarning("OnHoldEvent: " + status + " " + position); }
private void SetOnHold() { try { using var _nat02Context = new NAT02Context(); if (!engineeringProject) { using var _projectsContext = new ProjectsContext(); using var _driveworksContext = new DriveWorksContext(); if (_projectsContext.HoldStatus.Any(p => p.ProjectNumber == projectNumber && p.RevisionNumber == revisionNumber)) { // Update data in HoldStatus HoldStatus holdStatus = _projectsContext.HoldStatus.Where(p => p.ProjectNumber == projectNumber && p.RevisionNumber == revisionNumber).First(); holdStatus.HoldStatus1 = "ON HOLD"; holdStatus.TimeSubmitted = DateTime.Now; holdStatus.OnHoldComment = CommentBox.Text; holdStatus.User = User.GetUserName() ?? Environment.UserName.ToLower(); _projectsContext.HoldStatus.Update(holdStatus); } else { // Insert into HoldStatus HoldStatus holdStatus = new HoldStatus(); holdStatus.ProjectNumber = projectNumber; holdStatus.RevisionNumber = revisionNumber; holdStatus.TimeSubmitted = DateTime.Now; holdStatus.HoldStatus1 = "ON HOLD"; holdStatus.OnHoldComment = CommentBox.Text; holdStatus.User = User.GetUserName() ?? Environment.UserName.ToLower(); _projectsContext.HoldStatus.Add(holdStatus); } // Drive specification transition name to "On Hold - " projectType string _name = projectNumber + (Convert.ToInt32(revisionNumber) > 0 ? "_" + revisionNumber : ""); Specifications spec = _driveworksContext.Specifications.Where(s => s.Name == _name).First(); spec.StateName = "On Hold - " + projectType; _driveworksContext.Specifications.Update(spec); var name = IMethods.GetDisplayNameFromDWPrincipalID(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).Csr).Split(' '); EoiNotificationsActive eoiNotificationsActive = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive); if (!string.IsNullOrEmpty(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).ReturnToCsr)) { name = IMethods.GetDisplayNameFromDWPrincipalID(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).ReturnToCsr).Split(' '); EoiNotificationsActive eoiNotificationsActive1 = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive1); } _projectsContext.SaveChanges(); _driveworksContext.SaveChanges(); _nat02Context.SaveChanges(); _projectsContext.Dispose(); _driveworksContext.Dispose(); _nat02Context.Dispose(); parent.BoolValue = true; } else { using var _projectsContext = new ProjectsContext(); EngineeringProjects eProject = _projectsContext.EngineeringProjects.First(p => p.ProjectNumber == projectNumber.ToString() && p.RevNumber == revisionNumber.ToString()); eProject.OnHold = true; eProject.OnHoldComment = CommentBox.Text; eProject.OnHoldDateTime = DateTime.UtcNow; eProject.OnHoldUser = User.GetUserName() ?? Environment.UserName.ToLower(); var name = IMethods.GetDisplayNameFromDWPrincipalID(eProject.CSR).Split(' '); EoiNotificationsActive eoiNotificationsActive = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive); if (!string.IsNullOrEmpty(eProject.ReturnToCSR) && eProject.ReturnToCSR.Length > 0) { name = IMethods.GetDisplayNameFromDWPrincipalID(eProject.ReturnToCSR).Split(' '); EoiNotificationsActive eoiNotificationsActive1 = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive1); } //string _name = projectNumber + (Convert.ToInt32(revisionNumber) > 0 ? "_" + revisionNumber : ""); //Specifications spec = _driveworksContext.Specifications.Where(s => s.Name == _name).First(); //spec.StateName = "On Hold - " + projectType; //_driveworksContext.Specifications.Update(spec); _projectsContext.SaveChanges(); _nat02Context.SaveChanges(); _projectsContext.Dispose(); _nat02Context.Dispose(); if (projectWindow != null) { projectWindow.PutOnHoldButton.Content = "Take Off Hold"; } } string path = @"R:\TOOLING AUTOMATION\Project Specifications\" + projectNumber + "\\"; if (File.Exists(path + "On_Hold_Comment.txt")) { int i = 1; while (File.Exists(path + "On_Hold_Comment_" + i + ".txt")) { i++; } path = path + "On_Hold_Comment_" + i + ".txt"; } try { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.Write("Comment: " + Environment.NewLine + CommentBox.Text + Environment.NewLine + Environment.NewLine + "Time: " + Convert.ToString(DateTime.Now) + Environment.NewLine + "User: "******"SetOnHold", ex.Message); } }
/// <summary> /// Retrieves holds for the supplied patron barcode as a staff member. /// </summary> /// <param name="barcode">The patron's barcode.</param> /// <param name="status">Status of the holds you wish to retrieve.</param> /// <returns>PatronHoldRequestsGetResult</returns> /// <seealso cref="PatronHoldRequestsGetResult"/> /// <seealso cref="HoldStatus"/> public PapiResponse <PatronHoldRequestsGetResult> PatronHoldRequestsGetOverride(string barcode, HoldStatus status) { var url = $"/PAPIService/REST/public/v1/1033/100/1/patron/{barcode}/holdrequests/{status}"; return(OverrideExecute <PatronHoldRequestsGetResult>(HttpMethod.Get, url)); }