Esempio n. 1
0
        /// <summary>
        /// Function used to determine how to handle a received request.
        /// </summary>
        /// <param name="ua">The ua.</param>
        /// <param name="request">The request.</param>
        /// <param name="stack">The stack.</param>
        public override void ReceivedRequest(UserAgent ua, Message request, SIPStack stack)
        {
            _log.Info("Received request with method " + request.Method.ToUpper());
            _log.Debug("\n\n" + request.ToString());
            switch (request.Method.ToUpper())
            {
            case "INVITE":
            {
                // Auto accepts any SIP INVITE request
                _log.Info("Generating 200 OK response for INVITE");
                Message m = ua.CreateResponse(200, "OK");
                ua.SendResponse(m);
                break;
            }

            case "CANCEL":
            {
                break;
            }

            case "ACK":
            {
                break;
            }

            case "BYE":
            {
                break;
            }

            case "MESSAGE":
            {
                // Logs any received request
                _log.Info("MESSAGE: " + request.Body);

                // Can also echo back any received message for testing purposes
                //Address from = (Address) request.first("From").value;
                //this.Message(from.uri.ToString(), request.body);
                break;
            }

            case "OPTIONS":
            case "REFER":
            case "SUBSCRIBE":
            case "NOTIFY":
            case "PUBLISH":
            case "INFO":
            default:
            {
                _log.Info("Request with method " + request.Method.ToUpper() + " is unhandled");
                break;
            }
            }
        }