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); } }
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; } }); }
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; }
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; }