public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; JSONRpcCall call = JSON.ParseRPC(new System.IO.StreamReader(request.InputStream)); object result = null; ISpellChecker spellchecker = new GoogleSpellChecker(); switch (call.Method) { case "checkWords": result = spellchecker.CheckWords((string)call.Args[0], (string[])((ArrayList)call.Args[1]).ToArray(typeof(string))); break; case "getSuggestions": result = spellchecker.GetSuggestions((string)call.Args[0], (string)call.Args[1]); break; } // Serialize RPC output JSON.SerializeRPC( call.Id, null, result, response.OutputStream ); }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <returns></returns> public static JSONRpcCall ParseRPC(TextReader reader) { JSONRpcCall call = new JSONRpcCall(); object obj = ParseJSON(reader); Hashtable jsonRpc = (Hashtable)obj; call.Method = (string)jsonRpc["method"]; call.Id = (string)jsonRpc["id"]; call.Args = (ArrayList)jsonRpc["params"]; return(call); }