コード例 #1
0
    private void RunInNewThread(object ctx)
    {
        //Get the param
        ServerParamData serverData = (ServerParamData)ctx;

        //Open the file and start sending it to the client
        WriteFile(serverData.context, serverData.path);
    }
コード例 #2
0
    void ListenToClient(object path)
    {
        //Get the param
        string dataPath = (string)path;

        HttpListener listener = new HttpListener();

        listener.Prefixes.Add(url);
        listener.Start();

        Debug.Log("Listening to Client");

        while (true)
        {
            HttpListenerContext context = listener.GetContext();
            Debug.LogWarning("New Client Connected: " + context.Request.RemoteEndPoint.ToString());

            //Construct param that will be sent to the Thread
            ServerParamData serverData = new ServerParamData(context, dataPath);
            ThreadPool.QueueUserWorkItem(new WaitCallback(RunInNewThread), serverData);
        }
    }