Ejemplo n.º 1
0
		protected SipMessageWriter GenerateResponse(SipMessageReader reader, StatusCodes statusCode)
		{
			var writer = GetWriter();
			writer.WriteResponse(reader, statusCode);

			return writer;
		}
Ejemplo n.º 2
0
		public static void WriteEmptyResponse(this HttpMessageWriter writer, StatusCodes statusCode)
		{
			writer.WriteStatusLine(statusCode);
			writer.WriteAuxiliaryHeaders();
			writer.WriteContentLength(0);
			writer.WriteCRLF();
		}
 public ExperimentStatus(StatusCodes statusCode, WaitEstimate waitEstimate, double estimatedRuntime, double estimatedRemainingRuntime)
 {
     this.statusCode = statusCode;
     this.waitEstimate = waitEstimate;
     this.estimatedRuntime = estimatedRuntime;
     this.estimatedRemainingRuntime = estimatedRemainingRuntime;
 }
Ejemplo n.º 4
0
		protected HttpMessageWriter CreateResponse(StatusCodes statusCodes, ContentType contentType, byte[] content)
		{
			var writer = Context.GetWriter();

			writer.WriteResponse(statusCodes, contentType, content);

			return writer;
		}
Ejemplo n.º 5
0
		protected HttpMessageWriter CreateNotFinishedResponse(StatusCodes statusCode, ContentType contentType)
		{
			var writer = Context.GetWriter();

			writer.WriteNotFinishedResponse(statusCode, contentType);

			return writer;
		}
Ejemplo n.º 6
0
		public void WriteStatusLine(StatusCodes statusCode)
		{
			Write(C.HTTP_1_1_);
			Write((int)statusCode);
			Write(C.SP);
			Write(statusCode.GetReason());
			Write(C.CRLF);
		}
Ejemplo n.º 7
0
		public void WriteResponse(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag)
		{
			WriteStatusLine(statusCode);
			CopyViaToFromCallIdRecordRouteCSeq(request, statusCode, localTag);
			WriteContentLength(0);
			WriteCustomHeaders();
			WriteCRLF();
		}
Ejemplo n.º 8
0
		protected HttpMessageWriter CreateResponse(StatusCodes statusCodes)
		{
			var writer = Context.GetWriter();

			writer.WriteEmptyResponse(statusCodes);

			return writer;
		}
Ejemplo n.º 9
0
		/// <summary>
		/// DEPRECATED!!! Не удобно читать код, не видно откуда CallLegTransactionDoesNotExist
		/// </summary>
		public Dialog GetOrCreate(SipMessageReader reader, ConnectionAddresses connectionAddresses, out StatusCodes statusCode)
		{
			var dialog = GetOrCreate(reader, connectionAddresses);

			statusCode = (dialog == null) ?
				StatusCodes.CallLegTransactionDoesNotExist : StatusCodes.OK;

			return dialog;
		}
Ejemplo n.º 10
0
		public static void WriteResponse(this HttpMessageWriter writer, StatusCodes statusCodes, ContentType contentType, byte[] content)
		{
			writer.WriteStatusLine(statusCodes);
			writer.WriteAuxiliaryHeaders();
			writer.WriteContentType(contentType);
			writer.WriteContentLength(content.Length);
			writer.WriteCRLF();
			writer.Write(content);
		}
Ejemplo n.º 11
0
		public static void WriteNotFinishedResponse(this HttpMessageWriter writer, StatusCodes statusCode, ContentType contentType)
		{
			writer.WriteStatusLine(statusCode);
			writer.WriteAuxiliaryHeaders();
			if (contentType != ContentType.None)
				writer.WriteContentType(contentType);
			else
				writer.WriteContentLength(0);
		}
Ejemplo n.º 12
0
		public void WriteStatusLineToTop(StatusCodes statusCode, ByteArrayPart reason)
		{
			WriteToTop(C.CRLF);
			WriteToTop(reason, 100);
			WriteToTop(C.SP);
			WriteToTop((uint)statusCode);
			WriteToTop(C.SP);
			WriteToTop(C.SIP_2_0);
		}
Ejemplo n.º 13
0
        protected override void LoadData()
        {
            base.LoadData();

            this.StatusCode = (StatusCodes)this.ReadUInt32();

            if (this.ProtocolVersion < 3)
            {
                return;
            }

            if (!this.IsEndOfData)
            {
                this.ErrorMessage = this.ReadString();
                this.Language = this.ReadString();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 正常关闭客户端
        /// </summary>      
        /// <param name="code">关闭码</param>
        /// <param name="reason">原因</param>
        public void Close(StatusCodes code, string reason)
        {
            var codeBytes = ByteConverter.ToBytes((ushort)(code), Endians.Big);
            var reasonBytes = Encoding.UTF8.GetBytes(reason ?? string.Empty);
            var content = new byte[codeBytes.Length + reasonBytes.Length];

            Array.Copy(codeBytes, 0, content, 0, codeBytes.Length);
            Array.Copy(reasonBytes, 0, content, codeBytes.Length, reasonBytes.Length);
            var response = new FrameResponse(FrameCodes.Close, content);

            try
            {
                this.SendResponse(response);
            }
            catch (Exception)
            {
            }
            finally
            {
                this.Close();
            }
        }
 //-------------------------------------------------------------------------------------------------//
 public ExperimentResultInfo()
 {
     this.statusCode = StatusCodes.Unknown;
     this.errorMessage = string.Empty;
 }
Ejemplo n.º 16
0
		protected void SendResponse(IncomingMessageEx request, StatusCodes statusCode)
		{
			SendResponseExternal(request.ConnectionAddresses, request.TransactionId,
				GenerateResponse(request.Reader, statusCode));
		}
Ejemplo n.º 17
0
		public void WriteResponse(StatusCodes statusCode)
		{
			WriteStatusLine(statusCode);
			WriteContentLength(0);
			WriteCRLF();
		}
 public ResultReport(StatusCodes statusCode)
 {
     this.statusCode = statusCode;
 }
Ejemplo n.º 19
0
		public void WriteStatusLine(StatusCodes statusCode, ByteArrayPart reason)
		{
			StatusCode = (int)statusCode;

			Write(C.SIP_2_0, C.SP, (int)statusCode, C.SP, reason, C.CRLF);
		}
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// Update the status of the specified experiment.
        /// </summary>
        /// <returns></returns>
        public bool UpdateStatus(int experimentId, string sbName, StatusCodes statusCode)
        {
            const string STRLOG_MethodName = "UpdateStatus";

            string logMessage = STRLOG_experimentId + experimentId.ToString() +
                Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + sbName + Logfile.STRLOG_Quote +
                Logfile.STRLOG_Spacer + STRLOG_statusCode + statusCode.ToString();

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            //
            // Catch all exceptions thrown and return false if an error occurred.
            //
            bool success = false;

            lock (this.queueLock)
            {
                try
                {
                    //
                    // Update queued experiment status
                    //
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_UpdateQueueStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_ExperimentId, experimentId));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_SbName, sbName));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_Status, statusCode.ToString()));

                    try
                    {
                        this.sqlConnection.Open();

                        success = (sqlCommand.ExecuteNonQuery() != 0);
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_success + success.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return success;
        }
 public MasterQueryResult(StatusCodes code, String message)
 {
     _message = message;
     _code = code;
 }
 public MasterQueryResult(List<Server> servers)
 {
     _code = StatusCodes.Success;
     _message = "";
     _mlist = servers;
 }
 public ResultReport(StatusCodes statusCode, string errorMessage)
 {
     this.statusCode = statusCode;
     this.errorMessage = errorMessage;
 }
 public ProtocolException(StatusCodes errorCode) 
     : this(errorCode, null)
 { }
 public ProtocolException(StatusCodes statusCode, Exception innerException)
     : base("Exception " + (int)statusCode + ": " + statusCode, innerException)
 {
     this.statusCode = statusCode;
 }
Ejemplo n.º 26
0
 public string error(StatusCodes status, string message, object detail = null) {
     if (service.errorLevel == ErrorLevels.debug) {
         if (service.alwaysLog && service.mainCB != null) {
             service.mainCB(status, message, detail);
         }
         return "{\"status\" : " + (int)status + ", \"message\" : \"" + message + "\"}";
     } else if (service.errorLevel == ErrorLevels.production) {
         if (service.alwaysLog && service.mainCB != null) {
             service.mainCB(status, message, detail);
         }
         return "{\"status\" : " + (int)status + "}";
     } else {
         if (service.mainCB != null) {
             service.mainCB(status, message, detail);
         }
         return "{\"status\" : " + (int)status + "}";
     }
 }
Ejemplo n.º 27
0
 StatusInfo ReportStatus(StatusCodes code, StatusSubCodes subCode, Exception exInfo)
 {
     StatusInfo iStatus = new StatusInfo();
     iStatus.Code = code;
     iStatus.SubCode = subCode;
     iStatus.UndeliningExceptionInfo = exInfo;
     return iStatus;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// 正常关闭客户端
 /// </summary>       
 /// <param name="code">关闭码</param>
 public void Close(StatusCodes code)
 {
     this.Close(code, string.Empty);
 }
        //---------------------------------------------------------------------------------------//
        public ExperimentInfo[] RetrieveAllWithStatus(StatusCodes status)
        {
            const string STRLOG_MethodName = "RetrieveAllWithStatus";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            List<ExperimentInfo> experimentInfoList = new List<ExperimentInfo>();

            lock (this.queueLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveQueueAllWithStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_Status, status.ToString()));

                    try
                    {
                        this.sqlConnection.Open();

                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        while (sqlDataReader.Read() == true)
                        {
                            ExperimentInfo experimentInfo = new ExperimentInfo(0, null);

                            //
                            // Get the experiment information from waiting experiment
                            //
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value)
                                experimentInfo.experimentId = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value)
                                experimentInfo.sbName = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value)
                                experimentInfo.userGroup = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value)
                                experimentInfo.priorityHint = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_XmlSpecification]) != System.DBNull.Value)
                                experimentInfo.xmlSpecification = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_EstimatedExecTime]) != System.DBNull.Value)
                                experimentInfo.estExecutionTime = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_Cancelled]) != System.DBNull.Value)
                                experimentInfo.cancelled = (bool)sdrObject;

                            //
                            // Add the experiment info to the list
                            //
                            experimentInfoList.Add(experimentInfo);
                        }
                        sqlDataReader.Close();
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            string logMessage = STRLOG_count + experimentInfoList.Count.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return experimentInfoList.ToArray();
        }
 //-------------------------------------------------------------------------------------------------//
 public ResultReport()
 {
     this.statusCode = StatusCodes.Unknown;
 }