コード例 #1
0
ファイル: RequestCoodinator.cs プロジェクト: jiaz/StreamFM
 public IRequestHandler GetRequestHandler(Request req)
 {
     IRequestHandler result = null;
     if (_handlerMap.TryGetValue(req.Action, out result))
     {
         // Log error
         Tracer.Trace(Assembly.GetExecutingAssembly().FullName, "Cannot find proper handler");
     }
     return result;
 }
コード例 #2
0
        private void StartListening()
        {
            while (true)
            {
                using (IClientSocket clientSocket = new ClientSocket(ListeningSocket.Accept()))
                {
                    Log.Debug("Received request from " + clientSocket.RemoteEndPoint);

                    Log.Debug(DateTime.Now + " " + clientSocket.Available + " request bytes available");

                    int bytesReceived = DetermineBytesReceived(clientSocket.Available);
                    if (bytesReceived > 0)
                    {
                        byte[] buffer = clientSocket.Receive(bytesReceived); // Buffer probably should be larger than this.

                        using (var r = new Request(clientSocket, Encoding.UTF8.GetChars(buffer)))
                        {
                            r.ProcessRequestHeader();
                            Log.Debug(DateTime.Now + " " + r.URL);
                            if (_requestReceived != null) _requestReceived(r);
                        }
                    }
                }

                // I always like to have this in a continuous loop. Helps prevent lock-ups
                Thread.Sleep(10);
            }
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: MRH4287/GameServer
        private Request commandData(Command request)
        {
            string command = request.command;

            try
            {
                Request requestData = new Request();
                requestData.condition = "";
                requestData.conditionValue = "";

                command = command.ToLower();
                string[] data = command.Split(new char[] { ' ' });

                // SQL Mäsige System Eingaben:
                dataManipulationMode dataMode = (dataManipulationMode)Enum.Parse(typeof(dataManipulationMode), data[0].ToUpper());
                requestData.dataMode = dataMode;

                dataManipulationSource dataSource = (dataManipulationSource)Enum.Parse(typeof(dataManipulationSource), data[1].ToUpper());
                requestData.source = dataSource;

                if (data.Length > 2)
                {

                    if (data[2] == "where")
                    {
                        if (data[3] == "contains")
                        {
                            requestData.contains = true;
                            if (data.Length > 4)
                                requestData.condition = data[4];
                        }
                        else
                        {
                            requestData.contains = false;
                            string[] conditionData = data[3].Split(new char[] { '=' });
                            requestData.condition = conditionData[0];
                            if (conditionData.Length > 1)
                                requestData.conditionValue = conditionData[1];
                        }

                    }
                }

                requestData.Arguments = request.Arguments;

                return requestData;

            }
            catch (Exception ex)
            {
                log("Fehler: " + ex.Message + " wegen:");
                log("Fehlerhafte Anweisung erhalten: " + command);
            }

            Request d = new Request();
            d.dataMode = dataManipulationMode.NONE;
            return d;
        }