コード例 #1
0
ファイル: HomeController.cs プロジェクト: bazizten/WCF_Chat
 public JsonResult SendMessage(string username, string chatType, string message)
 {
     try
     {
         ChatServiceClient client = new ChatServiceClient(chatType);
         client.SubmitChat(new Message
         {
             Comment = message,
             ChatType = (ChatType) Enum.Parse(typeof (ChatType), chatType),
             Submitter = username
         });
         return Json(new WcfResult("Message sent", true), JsonRequestBehavior.AllowGet);
     }
     catch (FaultException ex)
     {
         return Json(new WcfResult(ex.Message, false), JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new WcfResult(ex.Message, false), JsonRequestBehavior.AllowGet);
     }
     
 }