diff options
author | Justin Clark-Casey (justincc) | 2013-07-06 00:12:48 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-07-06 00:12:48 +0100 |
commit | 5dbdd5f8b4856357340357394edc2f9e229a0582 (patch) | |
tree | 23d061f124e946327888928fbd2bf618f99a5b18 /OpenSim/Region/Application/OpenSimBase.cs | |
parent | Add very basic regression test TestChildAgentSingleRegionCapabilities() which... (diff) | |
download | opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.zip opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.gz opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.bz2 opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.xz |
refactor: Make stats and sim status simpler by extending BaseStreamHandler like other handlers instead of implementing the IStreamedRequestHandler interface directly
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 74 |
1 files changed, 17 insertions, 57 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 7ca87a3..841069c 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -759,73 +759,49 @@ namespace OpenSim | |||
759 | /// <summary> | 759 | /// <summary> |
760 | /// Handler to supply the current status of this sim | 760 | /// Handler to supply the current status of this sim |
761 | /// </summary> | 761 | /// </summary> |
762 | /// <remarks> | ||
762 | /// Currently this is always OK if the simulator is still listening for connections on its HTTP service | 763 | /// Currently this is always OK if the simulator is still listening for connections on its HTTP service |
763 | public class SimStatusHandler : IStreamedRequestHandler | 764 | /// </remarks> |
765 | public class SimStatusHandler : BaseStreamHandler | ||
764 | { | 766 | { |
765 | public byte[] Handle(string path, Stream request, | 767 | public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {} |
768 | |||
769 | public override byte[] Handle(string path, Stream request, | ||
766 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 770 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
767 | { | 771 | { |
768 | return Util.UTF8.GetBytes("OK"); | 772 | return Util.UTF8.GetBytes("OK"); |
769 | } | 773 | } |
770 | 774 | ||
771 | public string Name { get { return "SimStatus"; } } | 775 | public override string ContentType |
772 | public string Description { get { return "Simulator Status"; } } | ||
773 | |||
774 | public string ContentType | ||
775 | { | 776 | { |
776 | get { return "text/plain"; } | 777 | get { return "text/plain"; } |
777 | } | 778 | } |
778 | |||
779 | public string HttpMethod | ||
780 | { | ||
781 | get { return "GET"; } | ||
782 | } | ||
783 | |||
784 | public string Path | ||
785 | { | ||
786 | get { return "/simstatus"; } | ||
787 | } | ||
788 | } | 779 | } |
789 | 780 | ||
790 | /// <summary> | 781 | /// <summary> |
791 | /// Handler to supply the current extended status of this sim | 782 | /// Handler to supply the current extended status of this sim |
792 | /// Sends the statistical data in a json serialization | 783 | /// Sends the statistical data in a json serialization |
793 | /// </summary> | 784 | /// </summary> |
794 | public class XSimStatusHandler : IStreamedRequestHandler | 785 | public class XSimStatusHandler : BaseStreamHandler |
795 | { | 786 | { |
796 | OpenSimBase m_opensim; | 787 | OpenSimBase m_opensim; |
797 | string osXStatsURI = String.Empty; | ||
798 | |||
799 | public string Name { get { return "XSimStatus"; } } | ||
800 | public string Description { get { return "Simulator XStatus"; } } | ||
801 | 788 | ||
802 | public XSimStatusHandler(OpenSimBase sim) | 789 | public XSimStatusHandler(OpenSimBase sim) |
790 | : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") | ||
803 | { | 791 | { |
804 | m_opensim = sim; | 792 | m_opensim = sim; |
805 | osXStatsURI = Util.SHA1Hash(sim.osSecret); | ||
806 | } | 793 | } |
807 | 794 | ||
808 | public byte[] Handle(string path, Stream request, | 795 | public override byte[] Handle(string path, Stream request, |
809 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 796 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
810 | { | 797 | { |
811 | return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); | 798 | return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); |
812 | } | 799 | } |
813 | 800 | ||
814 | public string ContentType | 801 | public override string ContentType |
815 | { | 802 | { |
816 | get { return "text/plain"; } | 803 | get { return "text/plain"; } |
817 | } | 804 | } |
818 | |||
819 | public string HttpMethod | ||
820 | { | ||
821 | get { return "GET"; } | ||
822 | } | ||
823 | |||
824 | public string Path | ||
825 | { | ||
826 | // This is for the OpenSimulator instance and is the osSecret hashed | ||
827 | get { return "/" + osXStatsURI; } | ||
828 | } | ||
829 | } | 805 | } |
830 | 806 | ||
831 | /// <summary> | 807 | /// <summary> |
@@ -834,42 +810,26 @@ namespace OpenSim | |||
834 | /// If the request contains a key, "callback" the response will be wrappend in the | 810 | /// If the request contains a key, "callback" the response will be wrappend in the |
835 | /// associated value for jsonp used with ajax/javascript | 811 | /// associated value for jsonp used with ajax/javascript |
836 | /// </summary> | 812 | /// </summary> |
837 | public class UXSimStatusHandler : IStreamedRequestHandler | 813 | public class UXSimStatusHandler : BaseStreamHandler |
838 | { | 814 | { |
839 | OpenSimBase m_opensim; | 815 | OpenSimBase m_opensim; |
840 | string osUXStatsURI = String.Empty; | ||
841 | |||
842 | public string Name { get { return "UXSimStatus"; } } | ||
843 | public string Description { get { return "Simulator UXStatus"; } } | ||
844 | 816 | ||
845 | public UXSimStatusHandler(OpenSimBase sim) | 817 | public UXSimStatusHandler(OpenSimBase sim) |
818 | : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") | ||
846 | { | 819 | { |
847 | m_opensim = sim; | 820 | m_opensim = sim; |
848 | osUXStatsURI = sim.userStatsURI; | ||
849 | |||
850 | } | 821 | } |
851 | 822 | ||
852 | public byte[] Handle(string path, Stream request, | 823 | public override byte[] Handle(string path, Stream request, |
853 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 824 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
854 | { | 825 | { |
855 | return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); | 826 | return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); |
856 | } | 827 | } |
857 | 828 | ||
858 | public string ContentType | 829 | public override string ContentType |
859 | { | 830 | { |
860 | get { return "text/plain"; } | 831 | get { return "text/plain"; } |
861 | } | 832 | } |
862 | |||
863 | public string HttpMethod | ||
864 | { | ||
865 | get { return "GET"; } | ||
866 | } | ||
867 | |||
868 | public string Path | ||
869 | { | ||
870 | // This is for the OpenSimulator instance and is the user provided URI | ||
871 | get { return "/" + osUXStatsURI; } | ||
872 | } | ||
873 | } | 833 | } |
874 | 834 | ||
875 | #endregion | 835 | #endregion |