Example #1
0
        void LateUpdate()
        {
            if (_netServer == null)
            {
                return;
            }

            _netServer.PollEvents();

            if (_ourPeer == null)
            {
                return;
            }

            if (logs.Count <= 0)
            {
                return;
            }

            string cMessage = "";

            for (int i = 0; i < logs.Count; i++)
            {
                cMessage = "";

                QueuedLog cLog = logs[i];
                cMessage = "::::" + cLog.type + "::::" + cLog.message + "\n" + cLog.stackTrace;
                _dataWriter.Reset();
                _dataWriter.Put(cMessage);
                _ourPeer.Send(_dataWriter, SendOptions.ReliableOrdered);
            }

            logs.Clear();
        }
        void HandleRequest(HTTPContext context)
        {
            // Debug.LogError("HANDLE " + context.Request.HttpMethod);
            // Debug.LogError("HANDLE " + context.path);

            bool foundCommand = false;

            switch (context.Command)
            {
            case "/NewLogs":
            {
                foundCommand = true;

                if (logs.Count > 0)
                {
                    string response = "";

                    //  foreach(QueuedLog cLog in logs)
                    for (int i = 0; i < logs.Count; i++)
                    {
                        QueuedLog cLog = logs[i];
                        response += "::::" + cLog.type;
                        response += "||||" + cLog.message;
                        response += ">>>>" + cLog.stackTrace + ">>>>";
                    }

                    context.RespondWithString(response);

                    logs.Clear();
                }
                else
                {
                    context.RespondWithString("");
                }
                break;
            }
            }

            if (!foundCommand)
            {
                context.Response.StatusCode        = (int)HttpStatusCode.NotFound;
                context.Response.StatusDescription = "Not Found";
            }

            context.Response.OutputStream.Close();
        }