Class HttpHostingService | Addressables | 1.13.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class HttpHostingService

    HTTP implemenation of hosting service.

    Inheritance
    Object
    BaseHostingService
    HttpHostingService
    Inherited Members
    BaseHostingService.Logger
    BaseHostingService.DisambiguateProfileVar(String)
    BaseHostingService.DescriptiveName
    BaseHostingService.InstanceId
    BaseHostingService.EvaluateProfileString(String)
    BaseHostingService.LogFormat(LogType, String, Object[])
    BaseHostingService.Log(String, Object[])
    BaseHostingService.LogWarning(String, Object[])
    BaseHostingService.LogError(String, Object[])
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEditor.AddressableAssets.HostingServices
    Syntax
    public class HttpHostingService : BaseHostingService, IHostingService

    Constructors

    HttpHostingService()

    Create a new HttpHostingService

    Declaration
    public HttpHostingService()

    Properties

    HostingServiceContentRoots

    List of content roots for hosting service.

    Declaration
    public override List<string> HostingServiceContentRoots { get; }
    Property Value
    Type Description
    List<String>
    Overrides
    BaseHostingService.HostingServiceContentRoots

    HostingServicePort

    The port number on which the service is listening

    Declaration
    public int HostingServicePort { get; protected set; }
    Property Value
    Type Description
    Int32

    IsHostingServiceRunning

    Gets the current running status of the hosting service.

    Declaration
    public override bool IsHostingServiceRunning { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    BaseHostingService.IsHostingServiceRunning

    MyHttpListener

    The actual Http listener used by this service

    Declaration
    protected HttpListener MyHttpListener { get; set; }
    Property Value
    Type Description
    HttpListener

    ProfileVariables

    Dictionary of profile variables defined by the hosting service.

    Declaration
    public override Dictionary<string, string> ProfileVariables { get; }
    Property Value
    Type Description
    Dictionary<String, String>
    Overrides
    BaseHostingService.ProfileVariables

    Methods

    ConfigureHttpListener()

    Handles any configuration necessary for MyHttpListener before listening for connections.

    Declaration
    protected virtual void ConfigureHttpListener()

    FindFileInContentRoots(String)

    Searches for the given relative path within the configured content root directores.

    Declaration
    protected virtual string FindFileInContentRoots(string relativePath)
    Parameters
    Type Name Description
    String relativePath
    Returns
    Type Description
    String

    The full system path to the file if found, or null if file could not be found

    GetAvailablePort()

    Find an open network listen port on the local system

    Declaration
    protected static int GetAvailablePort()
    Returns
    Type Description
    Int32

    a system assigned port, or 0 if none are available

    HandleRequest(IAsyncResult)

    Asynchronous callback to handle a client connection request on MyHttpListener. This method is recursive in that it will call itself immediately after receiving a new incoming request to listen for the next connection.

    Declaration
    protected virtual void HandleRequest(IAsyncResult ar)
    Parameters
    Type Name Description
    IAsyncResult ar

    Asynchronous result from previous request. Pass null to listen for an initial request

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    thrown when the request result code is unknown

    IsPortAvailable(Int32)

    Tests to see if the given port # is already in use

    Declaration
    protected static bool IsPortAvailable(int port)
    Parameters
    Type Name Description
    Int32 port

    port number to test

    Returns
    Type Description
    Boolean

    true if there is not a listener on the port

    OnAfterDeserialize(KeyDataStore)

    Called immediatley following a domain reload by the HostingServicesManager, for restoring state information after the service is recreated.

    Declaration
    public override void OnAfterDeserialize(KeyDataStore dataStore)
    Parameters
    Type Name Description
    KeyDataStore dataStore

    A key/value pair data store for use in restoring state information

    Overrides
    BaseHostingService.OnAfterDeserialize(KeyDataStore)

    OnBeforeSerialize(KeyDataStore)

    Called by the HostingServicesManager before a domain reload, giving the hosting service an opportunity to persist state information.

    Declaration
    public override void OnBeforeSerialize(KeyDataStore dataStore)
    Parameters
    Type Name Description
    KeyDataStore dataStore

    A key/value pair data store for use in persisting state information

    Overrides
    BaseHostingService.OnBeforeSerialize(KeyDataStore)

    OnGUI()

    Render the hosting service GUI.

    Declaration
    public override void OnGUI()
    Overrides
    BaseHostingService.OnGUI()

    ResetListenPort(Int32)

    Listen on a new port then next time the server starts. If the server is already running, it will be stopped and restarted automatically.

    Declaration
    public void ResetListenPort(int port = 0)
    Parameters
    Type Name Description
    Int32 port

    Specify a port to listen on. Default is 0 to choose any open port

    Return404(HttpListenerContext)

    Sets the status code to 404 on the given object

    Declaration
    protected virtual void Return404(HttpListenerContext context)
    Parameters
    Type Name Description
    HttpListenerContext context

    ReturnFile(HttpListenerContext, String, Int32)

    Sends a file to the connected HTTP client

    Declaration
    protected virtual void ReturnFile(HttpListenerContext context, string filePath, int readBufferSize = 65536)
    Parameters
    Type Name Description
    HttpListenerContext context
    String filePath
    Int32 readBufferSize

    StartHostingService()

    Starts the hosting service.

    Declaration
    public override void StartHostingService()
    Overrides
    BaseHostingService.StartHostingService()

    StopHostingService()

    Stops the hosting service.

    Declaration
    public override void StopHostingService()
    Overrides
    BaseHostingService.StopHostingService()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023