Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
    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;
                }
            }
        }
    }
Ejemplo n.º 3
0
    public static void Main()
    {
        PhoneHandler handler = new PhoneHandler();

        handler.start();
    }
Ejemplo n.º 4
0
 public LinkInterestHandler(PhoneHandler handler)
 {
     phoneHandler_ = handler;
 }
Ejemplo n.º 5
0
 public FetchInterestHandler(PhoneHandler handler)
 {
     phoneHandler_ = handler;
 }
Ejemplo n.º 6
0
 public PhoneHandlerTest()
 {
     Sut = new PhoneHandler();
 }