コード例 #1
0
        public MyResponse Login([FromBody] UserVM model)
        {
            MyResponse myResponse = new MyResponse();

            try
            {
                User us = new User {
                    Id = model.Id
                };

                User usLog = dBContext.Find <User>(us);
                if (usLog != null)
                {
                    //  Session["USER_ID"] = usLog.Id;
                    myResponse.Success = 1;
                }
                myResponse.Success = 0;
            }
            catch (Exception ex)
            {
                myResponse.Success = 0;
                myResponse.Message = ex.Message;
            }
            return(myResponse);
        }
コード例 #2
0
        /// <summary>
        /// Permet à un utilisateur de récupérer son mot de passe via un token envoyé au préalable
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <param name="token"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> RecoverPassword(string userId, string password, string token)
        {
            if (!String.IsNullOrWhiteSpace(userId) && !String.IsNullOrWhiteSpace(password) && !String.IsNullOrWhiteSpace(token))
            {
                User user = await _userManager.FindByIdAsync(userId);

                if (user != null)
                {
                    var result = await _userManager.ResetPasswordAsync(user, token, password);

                    if (result.Succeeded)
                    {
                        return(new MyResponse {
                            Succeeded = true
                        });
                    }

                    MyResponse error = new MyResponse {
                        Succeeded = false
                    };

                    result.Errors.ToList().ForEach(err =>
                    {
                        error.Messages.Add(err.Code);
                    });

                    return(error);
                }
            }

            return(new MyResponse {
                Succeeded = false
            });
        }
コード例 #3
0
ファイル: SbuController.cs プロジェクト: lyc524/AmbAPI
        public HttpResponseMessage GetOne(string id)
        {
            MyResponse response = new MyResponse();

            try
            {
                SBU sbu = db.SBU.Find(id);
                if (sbu == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }
                string json = JsonConvert.SerializeObject(sbu);
                response.Data = json;
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(new HttpResponseMessage {
                Content = new StringContent(response.ToString(), System.Text.Encoding.UTF8, "application/json")
            });
        }
コード例 #4
0
ファイル: PostService.cs プロジェクト: Junaagnah/Projet_Forum
        /// <summary>
        /// Permet de récupérer un post via son Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> GetPost(int id)
        {
            Post post = _repository.GetPost(id);

            if (post != null)
            {
                // On rajoute le nom de l'auteur à la réponse
                var user = await _identityService.GetUserById(post.Author);

                if (user != null)
                {
                    post.AuthorUsername = user.UserName;
                }
                else
                {
                    // Si on ne trouve pas l'utilisateur, on renvoie quand même le post avec le nom d'utilisateur 'Utilisateur inexistant'
                    post.AuthorUsername = "******";
                }

                MyResponse response = new MyResponse {
                    Succeeded = true
                };
                response.Result = post;

                return(response);
            }

            var error = new MyResponse {
                Succeeded = false
            };

            error.Messages.Add("PostNotFound");

            return(error);
        }
コード例 #5
0
        public ActionResult <MyResponse> LegalAge([FromBody] Person person)
        {
            MyResponse response;

            if (!ModelState.IsValid)
            {
                response = new MyResponse {
                    IsSuccess = false, Message = "Error"
                };
                return(BadRequest(response));
            }

            if (person.Age < 18)
            {
                response = new MyResponse {
                    IsSuccess = false, Message = "Not legal age"
                };
                return(BadRequest(response));
            }
            else if (!person.Name.ToLower().Contains("x"))
            {
                response = new MyResponse {
                    IsSuccess = false, Message = "x is not found in the name string"
                };
                return(NotFound(response));
            }

            response = new MyResponse {
                IsSuccess = true, Message = "Success"
            };
            return(Ok(response));
        }
コード例 #6
0
ファイル: SbuController.cs プロジェクト: lyc524/AmbAPI
        public string Delete(string id)
        {
            MyResponse response = new MyResponse();

            try
            {
                SBU sbu = db.SBU.Find(id);
                if (sbu == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }

                db.SBU.Remove(sbu);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }

            return(response.ToString());
        }
コード例 #7
0
        public override void OnResultExecuting(ResultExecutingContext context)
        {
            var response = new MyResponse <object> ();

            response.Entities = null;

            if (!context.ModelState.IsValid)
            {
                var errorMessages = context.ModelState.Values.SelectMany(value => value.Errors).Select(value => value.ErrorMessage);
                response.ErrorsMessage = errorMessages.ToList();
                context.Result         = new BadRequestObjectResult(response);
            }
            else if (context.ModelState.IsValid && context.Result is OkObjectResult okResult)
            {
                response.Entities = okResult.Value;
                context.Result    = new OkObjectResult(response);
            }
            else if (context.ModelState.IsValid && context.Result is CreatedResult createdResult)
            {
                response.Entities = createdResult.Value;
                context.Result    = new CreatedResult("", response);
            }

            Console.WriteLine("Hello from ResponseModelAttribute");
        }
コード例 #8
0
        public MyResponse Add([FromBody] ServicioPaisViewModel ServicioPaisAgregar)
        {
            MyResponse Res = new MyResponse();

            try
            {
                if (ServicioPaisAgregar != null)
                {
                    var resultadopais     = db.paises.FirstOrDefault(p => p.Id == ServicioPaisAgregar.fk_IdPais.Id);
                    var resultadoservicio = db.servicios.FirstOrDefault(p => p.Id == ServicioPaisAgregar.fK_IdServicio.Id);

                    Models.Servicios_Pais oServicioPais = new Models.Servicios_Pais();
                    oServicioPais.fk_IdPais     = resultadopais;
                    oServicioPais.fK_IdServicio = resultadoservicio;

                    db.servicios_pais.Add(oServicioPais);
                    db.SaveChanges();
                    Res.Success = 1;
                }
                else
                {
                    Res.Message = "Sericio Nulo";
                }
            }
            catch (Exception e)
            {
                Res.Success = 0;
                Res.Message = e.Message;
            }
            return(Res);
        }
コード例 #9
0
        public MyResponse getMyResponse(int userId)
        {
            var user      = apiHelper.GetUser(userId);
            var userPosts = apiHelper.GetPosts(userId);

            MyResponse myResponse = new MyResponse
            {
                id       = user.Id,
                name     = user.Name,
                username = user.Username,
                email    = user.Email,
                posts    = new List <Post>()
            };

            myResponse.posts.AddRange(userPosts);

            foreach (var post in myResponse.posts)
            {
                var postComments = apiHelper.GetPostComments(post.Id);
                post.Comments = new List <Comment>();
                post.Comments.AddRange(postComments);
            }

            return(myResponse);
        }
コード例 #10
0
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        var responseObject = JObject.Load(reader);

        MyResponse response = new MyResponse
        {
            StartTime = (string)responseObject["starttime"],
            EndTime   = (string)responseObject["endtime"],
        };

        var varData = new Dictionary <string, object>();

        foreach (var property in responseObject.Properties())
        {
            if (property.Name == "starttime" || property.Name == "endtime")
            {
                continue;
            }

            varData.Add(property.Name, property.Value);
        }

        response.VarData = varData;
        return(response);
    }
コード例 #11
0
        public MyResponse Add([FromBody] MessageViewModel model)
        {
            MyResponse oR = new MyResponse();

            //var result = db.User.Where(c => c.FirstName == "Cesar" & c.SurName == "Arcos").FirstOrDefault();

            try
            {
                Models.User oMessage = new Models.User();
                oMessage.FirstName      = model.FirstName;
                oMessage.SurName        = model.SurName;
                oMessage.Identification = model.Identification;
                oMessage.Password       = model.Password;
                oMessage.Email          = model.Email;
                db.User.Add(oMessage);
                db.SaveChanges();
                oR.Success = 1;
            }
            catch (Exception ex)
            {
                oR.Success = 0;
                oR.Message = ex.Message;
            }
            return(oR);
        }
コード例 #12
0
        /// <summary>
        /// 例用suo.im转短链接
        /// </summary>
        /// <param name="cqMsg"></param>
        /// <returns></returns>
        public static MyResponse <MovieInfo> CovertInSuoIm(string cqMsg)
        {
            //不做是否是支持的转换平台

            /*
             * bool isContain = false;
             * foreach(string canParsePlatform in SystemConfig.CanParsePlatform)
             * {
             *  if (cqMsg.Contains(canParsePlatform))
             *  {
             *      isContain = true;
             *      break;
             *  }
             * }
             *
             * if (!isContain)
             * {
             *
             *  return new MyResponse<MovieInfo>(1,null);
             * }
             */

            MovieInfo movieInfo = Covert(cqMsg);

            //转成短网址,例用suo.im
            movieInfo.Url = MyUrlTool.HttpGet("http://suo.im/api.php?url=" + movieInfo.Url, "");


            MyResponse <MovieInfo> myResponse = new MyResponse <MovieInfo>(0, movieInfo);

            return(myResponse);
        }
コード例 #13
0
        public string Delete(string code)
        {
            MyResponse response = new MyResponse();

            try
            {
                User user = db.User.Find(code);
                if (user == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }
                db.User.Remove(user);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(response.ToString());
        }
コード例 #14
0
        public HttpResponseMessage GetOne(string token)
        {
            MyResponse response = new MyResponse();

            try
            {
                AmbToken t = db.AmbToken.FirstOrDefault <AmbToken>(X => X.Token == token);
                if (t == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }

                User u = db.User.FirstOrDefault <User>(X => X.UserCode == t.Code);
                if (u == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }
                string json = JsonConvert.SerializeObject(u);
                response.Data = json;
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(new HttpResponseMessage {
                Content = new StringContent(response.ToString(), System.Text.Encoding.UTF8, "application/json")
            });
        }
コード例 #15
0
        public JsonResult SnimiPredmet(short tipDokumenta, string predmetJ, short?kolicina, bool?bezStampe)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                var ser     = new JavaScriptSerializer();
                var predmet = ser.Deserialize <Predmet>(predmetJ);

                if (korisnik.IdOkruga != null)
                {
                    predmet.IdOkruga = (short)korisnik.IdOkruga;
                }

                var zaglavlje = PredmetiData.SnimiPredmet(korisnik, tipDokumenta, predmet, kolicina);
                if (bezStampe != true)
                {
                    if (tipDokumenta == 2)
                    {
                        zaglavlje.Stampa = IzvestajiData.VratiStampeRezervisanihBrojevaPredmeta(korisnik, zaglavlje);
                    }
                    res.Data = zaglavlje;
                }
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.DenyGet));
        }
コード例 #16
0
        public MyResponse Login([FromBody] Login model)
        {
            MyResponse oR = new MyResponse();

            try
            {
                User user = _context.Users.FirstOrDefault(x => x.Email == model.Email);

                if (user == null)
                {
                    oR.Success = 0;
                    oR.Message = "Usuario o Password incorrecrtos";
                    return(oR);
                }

                if (user.Password != model.Password)
                {
                    oR.Success = 0;
                    oR.Message = "Usuario o Password incorrecrtos";
                    return(oR);
                }

                oR.Success = 1;
                oR.Message = "Success";
                oR.Data    = user;

                return(oR);
            }
            catch (Exception ex)
            {
                oR.Success = 0;
                oR.Message = ex.Message;
                return(oR);
            }
        }
コード例 #17
0
        public JsonResult SnimiIstorijuPredmeta(long idPredmeta, short vrstaKretanja, string napomena, string datumRokaJ)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                var      ser       = new JavaScriptSerializer();
                DateTime?datumRoka = null;

                if (!string.IsNullOrEmpty(datumRokaJ))
                {
                    datumRoka = ser.Deserialize <DateTime>(datumRokaJ);
                }

                res.Data = PredmetiData.SnimiIstorijuPredmeta(korisnik, idPredmeta, vrstaKretanja, napomena, datumRoka);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.DenyGet));
        }
コード例 #18
0
        public string GetOne(int id)
        {
            MyResponse response = new MyResponse();

            try
            {
                News news = db.News.Find(id);
                if (news == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }
                string json = JsonConvert.SerializeObject(news);
                response.Data = json;
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(response.ToString());
        }
コード例 #19
0
        public MyResponse Login([FromBody] UserVM model)
        {
            MyResponse myResponse = new MyResponse();

            try
            {
                User us = new User {
                    Id = model.Id
                };

                User usLog = dBContext.Find <User>(us);
                if (usLog != null)
                {
                    HttpContext.Session.SetString(USER_ID, model.Id.ToString());
                    myResponse.Success = 1;
                }
                myResponse.Success = 0;
            }
            catch (Exception ex)
            {
                myResponse.Success = 0;
                myResponse.Message = ex.Message;
            }
            return(myResponse);
        }
コード例 #20
0
ファイル: SbuController.cs プロジェクト: lyc524/AmbAPI
        public string Update(SBU sbu)
        {
            MyResponse response = new MyResponse();

            try
            {
                //判断要改的新名字是否存在
                SBU _sbu = db.SBU.Find(sbu.Name);
                if (_sbu == null)
                {
                    throw new Exception(StatusCode.ObjectNotFound.ToString());
                }
                db.Entry(sbu).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(response.ToString());
        }
コード例 #21
0
        public MyResponse Add([FromBody] ServicioViewModel ServicioAgregar)
        {
            MyResponse Res = new MyResponse();

            try
            {
                if (ServicioAgregar != null)
                {
                    var resultado = db.clientes.FirstOrDefault(p => p.Id == ServicioAgregar.fk_Cliente.Id);


                    Models.Servicios oServicio = new Models.Servicios();
                    oServicio.valorxHora     = ServicioAgregar.valorxHora;
                    oServicio.nombreServicio = ServicioAgregar.nombreServicio;
                    oServicio.fk_Cliente     = resultado;

                    db.servicios.Add(oServicio);
                    db.SaveChanges();
                    Res.Success = 1;
                }
                else
                {
                    Res.Message = "Sericio Nulo";
                }
            }
            catch (Exception e)
            {
                Res.Success = 0;
                Res.Message = e.Message;
            }
            return(Res);
        }
コード例 #22
0
ファイル: SbuController.cs プロジェクト: lyc524/AmbAPI
        public HttpResponseMessage GetList()
        {
            MyResponse response = new MyResponse();

            try
            {
                List <SBU> sbuList = db.SBU.ToList();
                string     json    = JsonConvert.SerializeObject(sbuList);
                response.Count = sbuList.Count.ToString();
                response.Data  = json;
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectNotFound.ToString())
                {
                    response.Code = StatusCode.ObjectNotFound;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(new HttpResponseMessage {
                Content = new StringContent(response.ToString(), System.Text.Encoding.UTF8, "application/json")
            });
        }
コード例 #23
0
        /// <summary>
        /// Permet de supprimer l'image attachée à un post
        /// </summary>
        /// <param name="postId"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> DeletePostImage(int postId, bool isTest = false)
        {
            // Si c'est un test on set à true
            var fileDeleteResult = isTest ? true : DeletePostImageFromDisk(postId);
            var dataDeleteResult = await _repository.DeletePostImage(postId);

            if (fileDeleteResult && dataDeleteResult)
            {
                return new MyResponse {
                           Succeeded = true
                }
            }
            ;

            var error = new MyResponse {
                Succeeded = false
            };

            if (!fileDeleteResult)
            {
                error.Messages.Add("FileNotDeleted");
            }
            if (!dataDeleteResult)
            {
                error.Messages.Add("EntryNotDeleted");
            }

            return(error);
        }
コード例 #24
0
ファイル: SbuController.cs プロジェクト: lyc524/AmbAPI
        public string Add(SBU sbu)
        {
            MyResponse response = new MyResponse();

            try
            {
                SBU _sbu = db.SBU.FirstOrDefault(X => X.Name == sbu.Name);
                if (_sbu != null)
                {
                    throw new Exception(StatusCode.ObjectHadExist.ToString());
                }
                db.SBU.Add(sbu);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (ex.Message == StatusCode.ObjectHadExist.ToString())
                {
                    response.Code = StatusCode.ObjectHadExist;
                }
                else
                {
                    response.Code = StatusCode.Error;
                }
            }
            return(response.ToString());
        }
コード例 #25
0
        /// <summary>
        /// Permet d'enregistrer une photo de profil
        /// </summary>
        /// <param name="img"></param>
        /// <param name="userId"></param>
        /// <param name="isTest"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> SaveProfilePicture(ImageModel img, string userId, bool isTest = false)
        {
            if (img != null && !String.IsNullOrWhiteSpace(userId) && !String.IsNullOrWhiteSpace(img.FileName) && !String.IsNullOrWhiteSpace(img.FileType) && !String.IsNullOrWhiteSpace(img.Value))
            {
                if (img.FileType == "image/jpeg" || img.FileType == "image/png")
                {
                    var filePath = await WriteProfilePictureToDisk(img, userId, isTest);

                    var result = await _repository.SaveProfilePicture(img.FileName, filePath, userId);

                    return(new MyResponse {
                        Succeeded = result
                    });
                }
                else
                {
                    // Type de fichier invalide, seuls jpeg & png acceptés
                    var error = new MyResponse {
                        Succeeded = false
                    };
                    error.Messages.Add("InvalidFileType");
                    return(error);
                }
            }

            return(new MyResponse {
                Succeeded = false
            });
        }
コード例 #26
0
ファイル: PostService.cs プロジェクト: Junaagnah/Projet_Forum
        /// <summary>
        /// Permet de récupérer la liste des posts
        /// </summary>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> GetPosts()
        {
            var posts = _repository.GetPosts();

            if (posts != null)
            {
                // On assigne le nom des auteurs à chaque post
                foreach (var post in posts)
                {
                    var user = await _identityService.GetUserById(post.Author);

                    if (user != null)
                    {
                        post.AuthorUsername = user.UserName;
                    }
                    else
                    {
                        post.AuthorUsername = "******";
                    }
                }

                MyResponse response = new MyResponse {
                    Succeeded = true
                };
                response.Result = posts;

                return(response);
            }

            return(new MyResponse {
                Succeeded = false
            });
        }
コード例 #27
0
        /// <summary>
        /// Permet d'enregistrer une image pour un post
        /// </summary>
        /// <param name="img"></param>
        /// <param name="postId"></param>
        /// <param name="isTest"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> SavePostImage(ImageModel img, int postId, bool isTest = false)
        {
            if (img != null && !String.IsNullOrWhiteSpace(img.FileName) && !String.IsNullOrWhiteSpace(img.FileType) && !String.IsNullOrWhiteSpace(img.Value))
            {
                if (img.FileType == "image/jpeg" || img.FileType == "image/png")
                {
                    var filePath = await WritePostImageToDisk(img, postId, isTest);

                    var result = await _repository.SavePostImage(img.FileName, filePath, postId);

                    return(new MyResponse {
                        Succeeded = result
                    });
                }
                else
                {
                    var error = new MyResponse {
                        Succeeded = false
                    };
                    error.Messages.Add("InvalidFileType");
                    return(error);
                }
            }

            return(new MyResponse {
                Succeeded = false
            });
        }
コード例 #28
0
        /// <summary>
        /// Permet à un utilisateur de demander un token par mail afin de renouveller son mot de passe
        /// </summary>
        /// <param name="email"></param>
        /// <returns>MyResponse</returns>
        public async Task <MyResponse> AskPasswordRecovery(string email)
        {
            if (!String.IsNullOrWhiteSpace(email))
            {
                User user = await _userManager.FindByEmailAsync(email);

                if (user != null)
                {
                    // Génération du token de récupération de mot de passe & envoi par mail
                    var token = await _userManager.GeneratePasswordResetTokenAsync(user);

                    var mailSent = await _sendgridService.SendRecoveryEmail(user.Email, user.Id, token);

                    if (!mailSent)
                    {
                        MyResponse error = new MyResponse {
                            Succeeded = false
                        };
                        error.Messages.Add("EmailNotSent");
                        return(error);
                    }
                }
            }

            // On renvoie toujours true pour éviter que des gens testent plusieurs adresses e-mail
            return(new MyResponse {
                Succeeded = true
            });
        }
コード例 #29
0
        public JsonResult UlogujKorisnika(string korisnickoIme, string lozinka)
        {
            HttpCookie langCookie = Request.Cookies["_lang"];
            var        jezik      = langCookie != null ? langCookie.Value : "0";

            var res = new MyResponse();

            try
            {
                var guid = LogovanjeData.UlogujKorisnika(Konverzija.KonvertujULatinicu(korisnickoIme), Konverzija.KonvertujULatinicu(lozinka), jezik);

                var cookie = new HttpCookie(RuntimeDataHelpers.LogKey, guid)
                {
                    Expires = DateTime.Now.AddHours(4)
                };
                HttpContext.Response.Cookies.Add(cookie);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(jezik, ex);
            }

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #30
0
    public void OnCipherOverWebServerTestClick1()
    {
        StartCoroutine(Http.SendGetRequest("http://127.0.0.1:808/login", (WWW www) => {
            Debug.Log(www.text);

            MyResponse jData = Newtonsoft.Json.JsonConvert.DeserializeObject <MyResponse>(www.text);
            NetworkLib.Cryptography.RSA.PublicKey publicKey = new NetworkLib.Cryptography.RSA.PublicKey(jData.publicKeyModulus, jData.publicKeyExponent);
            byte[] encText = NetworkLib.Cryptography.RSA.Encryption("haha하하!", publicKey, false);

            string sessionId = GetSessionId(www);
            Debug.Log(sessionId);
            Dictionary <string, string> cookie = new Dictionary <string, string>();
            cookie.Add("COOKIE", sessionId);

            StartCoroutine(Http.SendPostRequest("http://127.0.0.1:808/hello", encText, cookie, (WWW www1) => {
                Debug.Log(www1.text);
            },
                                                (string err) => {
                Debug.Log(err);
            }
                                                ));
        },
                                           (string err) => {
            Debug.Log(err);
        }
                                           ));
    }
コード例 #31
0
        // It is called when a message is received.
        private static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs<MyRequest> e)
        {
            Console.WriteLine("Received: " + e.RequestMessage.Text);

            // Create the response message.
            MyResponse aResponse = new MyResponse();
            aResponse.Length = e.RequestMessage.Text.Length;

            // Send the response message back to the client.
            myReceiver.SendResponseMessage(e.ResponseReceiverId, aResponse);
        }