public JsonResult Handshake(string method, string sendTo) { try { string code = CreateCookie("Handshake"); if (method == "email") { if (code != null) { EmailHandler emailHadler = new EmailHandler(); EmailModel request = new EmailModel(); request.toEmail = sendTo; request.subject = "Verification"; request.body = "Verification code: " + code; if (!emailHadler.SendEmail(request)) { return(Json(ResponseMessages.SendEmailException, JsonRequestBehavior.AllowGet)); } } else { return(Json(ResponseMessages.CodeGenerationException, JsonRequestBehavior.AllowGet)); } } else { if (code != null) { UserInformation userInformation = db.UserInformations.Where(x => x.email == sendTo).SingleOrDefault(); if (userInformation != null) { PhoneHandler handler = new PhoneHandler(); if (handler.SendSms(code, userInformation.phone) == ResponseMessages.SMSException) { return(Json(ResponseMessages.SMSException, JsonRequestBehavior.AllowGet)); } } else { return(Json(ResponseMessages.UnexpectedSystemException, JsonRequestBehavior.AllowGet)); } } else { return(Json(ResponseMessages.CodeGenerationException, JsonRequestBehavior.AllowGet)); } } return(Json(ResponseMessages.Success, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Console.WriteLine(e); return(Json(ResponseMessages.UnexpectedSystemException, JsonRequestBehavior.AllowGet)); } }
public void start() { // generic face setup face_ = new Face(new TcpTransport(), new TcpTransport.ConnectionInfo(hostName_)); bootstrap_ = new Bootstrap(face_); keyChain_ = bootstrap_.setupDefaultIdentityAndRoot(new Name(instanceName_), new Name()); certificateName_ = bootstrap_.getDefaultCertificateName(); // class-specific start memoryContentCache_ = new MemoryContentCache(face_); fetchPrefix_ = new Name(instanceName_).append(fetchVerb); linkPrefix_ = new Name(instanceName_).append(linkVerb); FetchInterestHandler fh = new FetchInterestHandler(this); memoryContentCache_.registerPrefix(fetchPrefix_, fh, fh); LinkInterestHandler lh = new LinkInterestHandler(this); face_.registerPrefix(linkPrefix_, lh, lh); // publish html content for given mobile, call when needed // for this example call this on start string htmlString = "<p>Hello world!</p>"; string mobileName = "/home/browser1"; publishHtmlForMobile(mobileName, htmlString); // update event while (true) { face_.processEvents(); System.Threading.Thread.Sleep(5); // dummy for testing repeated fetch on consumer if (nextThreshold_ > 0) { cycleCount_ += 1; if (cycleCount_ > nextThreshold_) { htmlString = "<p>" + PhoneHandler.randomString(5) + "</p>"; publishHtmlForMobile(mobileName, htmlString); cycleCount_ = 0; } } } }
public static void Main() { PhoneHandler handler = new PhoneHandler(); handler.start(); }
public LinkInterestHandler(PhoneHandler handler) { phoneHandler_ = handler; }
public FetchInterestHandler(PhoneHandler handler) { phoneHandler_ = handler; }
public PhoneHandlerTest() { Sut = new PhoneHandler(); }