예제 #1
0
        public bool login(string username, string password)
        {
            Payload p = Payload.makePayload();

            p.request = "login";
            p.addPayload("username", username);
            p.addPayload("password", password);
            p.addPayload("sessionkey", "");
            connector.Send(p);
            ResponsePayload r = connector.waitForPayload();

            if (r.status == "success")
            {
                identity = r.identity;
                Object k;
                r.payload.TryGetValue("sessionid", out k);
                sessionID = Convert.ToInt32(k);
                return(true);
            }
            else
            {
                currentError = r.message;
                return(false);
            }
        }
예제 #2
0
 void pingHost()
 {
     Task.Factory.StartNew(() =>
     {
         ping  = DateTime.Now;
         var p = Payload.makePayload("ping");
         connector.Send(p);
         NotifyPayload r         = null;
         connector.ReceivedData += (sender, e) =>
         {
             r = e.payload;
         };
         Task t = Task.Factory.StartNew(() =>
         {
             while (r == null)
             {
             }
         });
         t.Wait(1000);
         if (r != null && r.status == "pong" && r.identity == p.identity)
         {
             pong = DateTime.Now;
         }
     });
 }
예제 #3
0
        public PingRequest(FibeClass fibeClass, string[] tagsArr)
        {
            this.ClassRequested = fibeClass;
            client = fibeClass.client;
            Tags   = new ObservableCollection <string>(tagsArr);
            RaisePropertyChanged("tagString");
            When      = DateTime.Now;
            isTalking = false;
            connector = fibeClass.connector;

            Payload p = client.makePayload();

            p.path    = ClassRequested.path.Concat(new String[] { "audio" }).ToArray();
            p.request = "enqueue";
            int timespan = this.timestamp;

            p.addPayload("time", timespan.ToString());
            p.addPayload("tags", tagsArr);
            p.sessionkey = client.SessionKey;
            p.sessionid  = client.SessionID;
            Random rnd = new Random();

            p.identity = packetIdentity = rnd.Next(Int32.MaxValue);
            connector.Send(p);
            connector.ReceivedData += waitForPermit;
        }
예제 #4
0
        public PingRequest(FibeClass fibeClass, string[] tagsArr)
        {
            this.ClassRequested = fibeClass;
            client = fibeClass.client;
            Tags = new ObservableCollection<string>(tagsArr);
            RaisePropertyChanged("tagString");
            When = DateTime.Now;
            isTalking = false;
            connector = fibeClass.connector;

            Payload p = client.makePayload();
            p.path = ClassRequested.path.Concat(new String[] {"audio"}).ToArray();
            p.request = "enqueue";
            int timespan = this.timestamp;
            p.addPayload("time", timespan.ToString());
            p.addPayload("tags", tagsArr);
            p.sessionkey = client.SessionKey;
            p.sessionid = client.SessionID;
            Random rnd = new Random();
            p.identity = packetIdentity = rnd.Next(Int32.MaxValue);
            connector.Send(p);
            connector.ReceivedData += waitForPermit;
        }