public ReplyData get_domain(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers) { ReplyData rd = new ReplyData(); string domainID = arguments[0]; DomainReplyData drd = new DomainReplyData(); PutIceServerResponse isres = new PutIceServerResponse(); isres.status = "success"; DomainMemory.DomainObject dobj = new DomainMemory.DomainObject(); drd.id = domainID; if (Session.Instance.DomainsMem.Itms.ContainsKey(domainID)) { dobj = Session.Instance.DomainsMem.Itms[domainID].Obj; } else { // return nothing! GetDomainError gde = new GetDomainError(); gde.status = "fail"; gde.data = new Dictionary <string, string>(); gde.data.Add("domain", "there is no domain with that ID"); rd.Status = 404; rd.Body = JsonConvert.SerializeObject(gde); return(rd); } drd.ice_server_address = dobj.IPAddr; drd.name = dobj.PlaceName; isres.domain = drd; rd.Status = 200; rd.Body = JsonConvert.SerializeObject(isres); return(rd); }
public ReplyData put_ice_address(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers) { ReplyData rd = new ReplyData(); string domainID = arguments[0]; DomainReplyData drd = new DomainReplyData(); PutIceServerRequest isr = JsonConvert.DeserializeObject <PutIceServerRequest>(body); PutIceServerResponse isres = new PutIceServerResponse(); if (Session.Instance.DomainsMem.SetIP(domainID, remoteIP.ToString(), isr.api_key)) { isres.status = "success"; } else { isres.status = "fail"; } drd.id = domainID; DomainMemory.DomainObject dobj = Session.Instance.DomainsMem.Itms[domainID].Obj; drd.ice_server_address = dobj.IPAddr; drd.name = dobj.PlaceName; isres.domain = drd; rd.Status = 200; rd.Body = JsonConvert.SerializeObject(isres); return(rd); }