Exemple #1
0
 private void OnReceiveCompletedHandler(string response)
 {
     Console.WriteLine(response);
     model.Header header = JsonConvert.DeserializeObject <model.Header>(response);
     if (header.Method.Equals("LOGIN") && header.Status.Equals(model.Status.Login.GRANTED.ToString()))
     {
         Console.WriteLine("Approved");
     }
 }
Exemple #2
0
        public void StartClient()
        {
            Start();
            model.Header h = new model.Header();
            h.Method = "LOGIN";
            h.Source = "CLIENT";
            h.Status = model.Status.Login.REQUEST.ToString();
            model.Login l = new model.Login();
            l.UserName = "******";
            l.Password = "******";
            h.Body     = l;
            var json = JsonConvert.SerializeObject(h);

            Send(string.Format("{0}", json));
            CloseClient();
        }
        public void StartClient()
        {
            Start();
            model.Header h = new model.Header();
            h.Method = "LOGIN";
            h.Source = "CLIENT";
            h.Status = model.Status.Login.REQUEST.ToString();
            model.Login l = new model.Login();
            l.UserName = "******";
            l.Password = "******";
            h.Body = l;
            var json = JsonConvert.SerializeObject(h);

            Send(string.Format("{0}", json));
            CloseClient();
        }
        private string OnReceiveDataHandler(string response)
        {
            var header = JsonConvert.DeserializeObject<model.Header>(response);
            if (header.Method.Equals("LOGIN") && header.Status.Equals(model.Status.Login.REQUEST.ToString()))
            {
                var body = header.Body.ToString();
                var login = JsonConvert.DeserializeObject<model.Login>(body);

                model.Header h = new model.Header();
                h.Method = "LOGIN";
                h.Source = "SERVER";
                h.Status = model.Status.Login.GRANTED.ToString();
                var jsonReply = JsonConvert.SerializeObject(h);
                return jsonReply;
            }

            string reply = string.Format("Server received the message: {0}", response);
            Console.WriteLine(reply);
            return reply;
        }
Exemple #5
0
        private string OnReceiveDataHandler(string response)
        {
            var header = JsonConvert.DeserializeObject <model.Header>(response);

            if (header.Method.Equals("LOGIN") && header.Status.Equals(model.Status.Login.REQUEST.ToString()))
            {
                var body  = header.Body.ToString();
                var login = JsonConvert.DeserializeObject <model.Login>(body);

                model.Header h = new model.Header();
                h.Method = "LOGIN";
                h.Source = "SERVER";
                h.Status = model.Status.Login.GRANTED.ToString();
                var jsonReply = JsonConvert.SerializeObject(h);
                return(jsonReply);
            }

            string reply = string.Format("Server received the message: {0}", response);

            Console.WriteLine(reply);
            return(reply);
        }