/// <summary> /// Send a Log Message to the Web Socket client. /// </summary> /// <param name="type">Type of the Log Message</param> /// <param name="message">Message Content.</param> /// <param name="data">Additional Data For Message.</param> /// <param name="ErrorMessage">Error Information for failiures.</param> /// <returns></returns> public bool SendLogMessage(string type, string message, string data) { try { FileLogger.Instance.LogMessage("Sending Log Message. Type=" + type + ". Message =" + message + ". Data =" + data); Dictionary <string, Hashtable> responseParams = new Dictionary <string, Hashtable>(); Hashtable Hashmessage = new Hashtable(); Hashtable Hashdata = new Hashtable(); Hashmessage.Add("Message", message); Hashdata.Add("Data", data); responseParams.Add("message", Hashmessage); responseParams.Add("data", Hashdata); Response logResponse = new Response(type, true, responseParams); string jsonResponse = JSONDataHandler.ToResponseString(logResponse); FileLogger.Instance.LogMessage("Sending Log Message. Raw=" + jsonResponse); currentSession.Send(jsonResponse); return(true); } catch (Exception exception) { FileLogger.Instance.LogException(exception); return(false); } }
/// <summary> /// Send a Response to the Web Socket client. /// </summary> /// <param name="response">Response Information.</param> /// <param name="ErrorMessage">Error Information for failiures.</param> /// <returns>Returns true if message sending was successful.</returns> public bool SendResponse(Response response) { try { string jsonResponse = JSONDataHandler.ToResponseString(response); Console.WriteLine("Sending Response."); FileLogger.Instance.LogMessage("Sending Response. Raw=" + jsonResponse); currentSession.Send(jsonResponse); return(true); } catch (Exception exception) { FileLogger.Instance.LogException(exception); return(false); } }