Exemplo n.º 1
0
 private bool pushOK(HTTPConnection connection)
 {
     connection.writeToContext("\nOK");
     return false;
 }
Exemplo n.º 2
0
 private bool pushError(HTTPConnection connection, string error)
 {
     connection.writeToContext("\nError: " + error);
     return false;
 }
Exemplo n.º 3
0
 private bool dataOK(HTTPConnection connection)
 {
     connection.writeToContext("\nQuery OK");
     return false;
 }
Exemplo n.º 4
0
        private bool handleDataRequest(HTTPConnection connection)
        {
            string command = connection.getArg("action");

            // commands
            if (command == "list")
            {
                List<ServerHost> hosts = serverDB.listServers();
                if( hosts.Count == 0)
                    connection.writeToContext("No Results\n");
                else
                {
                    // parse players
                    XmlSerializer xml = new XmlSerializer(typeof(List<ServerHost>));

                    MemoryStream memStream = new MemoryStream();

                    StreamWriter writer = new StreamWriter(memStream);
                    xml.Serialize(writer, hosts);
                    writer.Close();

                    memStream.Seek(0, SeekOrigin.Begin);
                    StreamReader reader = new StreamReader(memStream);
                    string temp = reader.ReadToEnd();
                 //   string temp = new string(System.Text.ASCIIEncoding.ASCII.GetChars(memStream.GetBuffer(),0,(int)memStream.Length));
                    reader.Close();
                    memStream.Close();

                    connection.writeToContext(temp);
                }
                return dataOK(connection);
            }

            return dataError(connection,"unknown request");
        }
Exemplo n.º 5
0
 private bool dataError(HTTPConnection connection, string error)
 {
     connection.writeToContext("\nQuery Error: " + error);
     return false;
 }