public PutInfo ( string header, string value ) : void | ||
header | string | The header |
value | string | The body |
return | void |
public static void AddSong(this Client client, string song, string artist, string album, byte[] file) { IXPFile request = new IXPFile(); request.NetworkFunction = "com.projectgame.music.music.addsong"; request.PutInfo("name", song); request.PutInfo("artist", artist); request.PutInfo("album", album); request.PutInfo("file", Convert.ToBase64String(file)); client.NoResponseRequest(request); }
public IXPFile NetworkGetTime() { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.clock.gettime"; file.PutInfo("hour", DateTime.Now.Hour.ToString()); file.PutInfo("minute", DateTime.Now.Minute.ToString()); file.PutInfo("second", DateTime.Now.Second.ToString()); return file; }
public IXPFile NetworkGetDate() { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.clock.getdate"; file.PutInfo("day", DateTime.Now.Day.ToString()); file.PutInfo("month", DateTime.Now.Month.ToString()); file.PutInfo("year", DateTime.Now.Year.ToString()); file.PutInfo("weekday", "" + (((int)DateTime.Now.DayOfWeek) - 1)); return file; }
public IXPFile NetworkGetColor(string light_id) { IReadOnlyCollection<HueLight> lights = HueHub.Bridge.HueLights; HueLight light = lights.FirstOrDefault(l => l.Id.Equals(light_id)); IXPFile res = new IXPFile(); res.NetworkFunction = "com.projectgame.huelightning.hue.getcolor"; res.PutInfo("bri", "" + light.Brightness); res.PutInfo("sat", "" + light.Saturation); res.PutInfo("hue", "" + light.Hue); return res; }
public IXPFile NetworkGetTimers() { IXPFile response = new IXPFile(); response.NetworkFunction = "com.projectgame.clock.timer.gettimers"; List<int> timers = TimerDbConnector.GetTimers(); response.PutInfo("timer_count", "" + timers.Count); for(int i = 0; i < timers.Count; i++) { response.PutInfo("timer_" + i, "" + timers[i]); } return response; }
public IXPFile NetworkGetAlarms() { IXPFile response = new IXPFile(); response.NetworkFunction = "com.projectgame.clock.alarm.getalarms"; List<int> alarms = AlarmDbConnector.GetAlarms(); response.PutInfo("alarm_count", "" + alarms.Count); for(int i = 0; i < alarms.Count; i++) { response.PutInfo("alarm_" + i, "" + alarms[i]); } return response; }
public IXPFile NetworkGetTimer(int timer_id) { IXPFile response = new IXPFile(); response.NetworkFunction = "com.projectgame.clock.timer.gettimer"; Timer timer = TimerDbConnector.GetTimer(timer_id); response.PutInfo("id", "" + timer.ID); response.PutInfo("name", "" + timer.Name); response.PutInfo("hours", "" + timer.Hours); response.PutInfo("minutes", "" + timer.Minutes); response.PutInfo("seconds", "" + timer.Seconds); return response; }
public static void DeleteAlarm(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.unregisteralarm"; file.PutInfo("alarm_id", "" + alarm.ID); client.NoResponseRequest(file); }
public static byte[] GetSongData(this Client client, int songId) { IXPFile request = new IXPFile(); request.NetworkFunction = "com.projectgame.music.music.getsongdata"; request.PutInfo("song_id", "" + songId); String response = client.SimpleRequest(request); return Convert.FromBase64String(response); }
public static Alarm GetAlarm(this Client client, int alarmId) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.getalarm"; file.PutInfo("alarm_id", "" + alarmId); IXPFile response = client.IXPRequest(file); Alarm alarm = new Alarm(); alarm.ID = int.Parse(response.GetInfoValue("id")); alarm.Name = response.GetInfoValue("name"); alarm.Hours = int.Parse(response.GetInfoValue("hours")); alarm.Minutes = int.Parse(response.GetInfoValue("minutes")); alarm.Seconds = int.Parse(response.GetInfoValue("seconds")); alarm.Mon = response.GetInfoValue("mon").Equals("TRUE"); alarm.Tue = response.GetInfoValue("tue").Equals("TRUE"); alarm.Wed = response.GetInfoValue("wed").Equals("TRUE"); alarm.Thu = response.GetInfoValue("thu").Equals("TRUE"); alarm.Fri = response.GetInfoValue("fri").Equals("TRUE"); alarm.Sat = response.GetInfoValue("sat").Equals("TRUE"); alarm.Sun = response.GetInfoValue("sun").Equals("TRUE"); alarm.Enabled = response.GetInfoValue("enabled").Equals("TRUE"); return alarm; }
public IXPFile NetworkGetSongs() { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.music.music.getsongs"; List<int> artists = MusicDbConnector.GetInterpreters(); file.PutInfo("artist_count", "" + artists.Count); int ic = 0; foreach(int artist in artists) { file.PutInfo("artist_" + ic + "_id", "" + artist); file.PutInfo("artist_" + ic + "_name", MusicDbConnector.GetInterpreterName(artist)); List<int> albums = MusicDbConnector.GetAlbums(artist); file.PutInfo("artist_" + ic + "_album_count", "" + albums.Count); int ac = 0; foreach(int album in albums) { file.PutInfo("artist_" + ic + "_album_" + ac + "_id", "" + album); file.PutInfo("artist_" + ic + "_album_" + ac + "_name", MusicDbConnector.GetAlbumName(album)); List<int> songs = MusicDbConnector.GetSongs(album); file.PutInfo("artist_" + ic + "_album_" + ac + "_song_count", "" + songs.Count); int sc = 0; foreach(int song in songs) { file.PutInfo("artist_" + ic + "_album_" + ac + "_song_" + sc + "_id", "" + song); file.PutInfo("artist_" + ic + "_album_" + ac + "_song_" + sc + "_name", MusicDbConnector.GetSongName(song)); sc++; } ac++; } ic++; } return file; }
public static void UpdateAlarmEnabled(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.setalarmenabled"; file.PutInfo("alarm_id", "" + alarm.ID); file.PutInfo("enabled", alarm.Enabled ? "TRUE" : "FALSE"); client.NoResponseRequest(file); }
public IXPFile NetworkGetLights() { IReadOnlyCollection<HueLight> lights = HueHub.Bridge.HueLights; IXPFile res = new IXPFile(); res.NetworkFunction = "com.projectgame.huelightning.hue.getlights"; res.PutInfo("Count", "" + lights.Count); for(int i = 0; i < lights.Count; i++) { res.PutInfo("" + i, lights.ElementAt(i).Id); } return res; }
public static void UpdateAlarmName(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.setalarmname"; file.PutInfo("alarm_id", "" + alarm.ID); file.PutInfo("name", alarm.Name); client.NoResponseRequest(file); }
public IXPFile NetworkGetFullAlarms() { IXPFile response = new IXPFile(); response.NetworkFunction = "com.projectgame.clock.alarm.getfullalarms"; List<int> alarmIDs = AlarmDbConnector.GetAlarms(); response.PutInfo("alarm_count", "" + alarmIDs.Count); for(int i = 0; i < alarmIDs.Count; i++){ Alarm alarm = AlarmDbConnector.GetAlarm(alarmIDs[i]); response.PutInfo("alarm_" + i + "_id", "" + alarm.ID); response.PutInfo("alarm_" + i + "_name", "" + alarm.Name); response.PutInfo("alarm_" + i + "_hours", "" + alarm.Hours); response.PutInfo("alarm_" + i + "_minutes", "" + alarm.Minutes); response.PutInfo("alarm_" + i + "_seconds", "" + alarm.Seconds); response.PutInfo("alarm_" + i + "_mon", alarm.Mon ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_tue", alarm.Tue ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_wed", alarm.Wed ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_thu", alarm.Thu ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_fri", alarm.Fri ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_sat", alarm.Sat ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_sun", alarm.Sun ? "TRUE" : "FALSE"); response.PutInfo("alarm_" + i + "_enabled", alarm.Enabled ? "TRUE" : "FALSE"); } return response; }
public static Alarm AddAlarm(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.registeralarm"; file.PutInfo("name", alarm.Name); file.PutInfo("hours", "" + alarm.Hours); file.PutInfo("minutes", "" + alarm.Minutes); file.PutInfo("seconds", "" + alarm.Seconds); file.PutInfo("mon", alarm.Mon ? "TRUE" : "FALSE"); file.PutInfo("tue", alarm.Tue ? "TRUE" : "FALSE"); file.PutInfo("wed", alarm.Wed ? "TRUE" : "FALSE"); file.PutInfo("thu", alarm.Thu ? "TRUE" : "FALSE"); file.PutInfo("fri", alarm.Fri ? "TRUE" : "FALSE"); file.PutInfo("sat", alarm.Sat ? "TRUE" : "FALSE"); file.PutInfo("sun", alarm.Sun ? "TRUE" : "FALSE"); file.PutInfo("enabled", alarm.Enabled ? "TRUE" : "FALSE"); int id = int.Parse(client.SimpleRequest(file)); alarm.ID = id; return alarm; }
private static void Work() { while (_running) { Thread.Sleep(1000); ; _timerSemaphore.Enqueue(); DateTime now = DateTime.Now; foreach(Timer timer in _timers.Keys) { if(timer == null) { Debug.Log(_debugChannel, "Timer is null. This should not happen"); continue; } _timers [timer].Subtract (new TimeSpan (0, 0, 1)); foreach(ServerInstance instance in _clients.Keys){ IXPFile file = new IXPFile(); file.NetworkFunction = _clients[instance][Function.UPDATED]; file.PutInfo("timer_id", "" + timer.ID); file.PutInfo("name", "" + timer.Name); file.PutInfo ("hours", "" + _timers[timer].Hours); file.PutInfo ("minutes", "" + _timers[timer].Minutes); file.PutInfo ("seconds", "" + _timers[timer].Seconds); instance.Send(Encoding.UTF8.GetBytes(file.XML)); } CallTimer(timer); } _timerSemaphore.Dequeue(); } }
public static void StopTimer(Timer timer) { _timers.Remove (timer); foreach(ServerInstance instance in _clients.Keys){ IXPFile file = new IXPFile(); file.NetworkFunction = _clients[instance][Function.STOPPED]; file.PutInfo("timer_id", "" + timer.ID); file.PutInfo("name", "" + timer.Name); instance.Send(Encoding.UTF8.GetBytes(file.XML)); } }
public static void UpdateAlarmWeekdays(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.setalarmweekdays"; file.PutInfo("alarm_id", "" + alarm.ID); file.PutInfo("mon", alarm.Mon ? "TRUE" : "FALSE"); file.PutInfo("tue", alarm.Tue ? "TRUE" : "FALSE"); file.PutInfo("wed", alarm.Wed ? "TRUE" : "FALSE"); file.PutInfo("thu", alarm.Thu ? "TRUE" : "FALSE"); file.PutInfo("fri", alarm.Fri ? "TRUE" : "FALSE"); file.PutInfo("sat", alarm.Sat ? "TRUE" : "FALSE"); file.PutInfo("sun", alarm.Sun ? "TRUE" : "FALSE"); client.NoResponseRequest(file); }
private static void Work() { while (_running) { Thread.Sleep(1000); _semaphore.Enqueue(); foreach(ServerInstance client in _clients.Keys) { IXPFile file = new IXPFile(); file.NetworkFunction = _clients[client]; file.PutInfo("hours", "" + DateTime.Now.Hour); file.PutInfo("minutes", "" + DateTime.Now.Minute); file.PutInfo("seconds", "" + DateTime.Now.Second); client.Send(Encoding.UTF8.GetBytes(file.XML)); } _semaphore.Dequeue(); } }
public static void RegisterToAlarmService(this Client client, string function) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.registertoalarmservice"; file.PutInfo("function", function); client.NoResponseRequest(file); }
private void button1_Click(object sender, EventArgs e) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.registeralarm"; file.PutInfo("name", "This is my test alarm"); file.PutInfo("hours", "17"); file.PutInfo("minutes", "45"); file.PutInfo("seconds", "00"); file.PutInfo("mon", "TRUE"); file.PutInfo("tue", "FALSE"); file.PutInfo("wed", "FALSE"); file.PutInfo("thu", "FALSE"); file.PutInfo("fri", "TRUE"); file.PutInfo("sat", "FALSE"); file.PutInfo("sun", "TRUE"); file.PutInfo("enabled", "TRUE"); IXPRequest request = new IXPRequest(_client, file, AddAlarm_Response); }
private static void HandleMessage(ServerInstance arg1, string message) { IXPFile ixp = new IXPFile(message); FunctionInfo nfunc = _networkFunctions.FirstOrDefault(nf => nf.Name.Equals(ixp.NetworkFunction)); if (nfunc != null) Debug.Log(_debugChannel, "Function: " + ixp.NetworkFunction); else { Debug.Log(_debugChannel, "Function: Unknown"); return; } Dictionary<string, object> dicParams = new Dictionary<string, object>(); foreach (string param in nfunc.Parameters) { if (ixp.GetInfoValue(param) == null && nfunc.GetParameterType(param) != typeof(ServerInstance)) { Debug.Log(_debugChannel, "Missing parameter: " + param); return; } object paramVal = null; Type t = nfunc.GetParameterType(param); if (t == typeof(ServerInstance)) { paramVal = arg1; } else { string strVal = ixp.GetInfoValue(param); if (t == typeof(string)) { paramVal = strVal; } else if (t == typeof(int)) { int i = -1; bool s = int.TryParse(strVal, out i); if (s) paramVal = i; } else if(t == typeof(byte)) { byte b = 0; bool s = byte.TryParse(strVal, out b); if (s) paramVal = b; } else if(t == typeof(ushort)){ ushort us = 0; bool s = ushort.TryParse(strVal, out us); if (s) paramVal = us; } else if (t == typeof(bool)) { if (strVal.Equals("TRUE")) paramVal = true; else if (strVal.Equals("FALSE")) paramVal = false; } if (paramVal == null) { Debug.Log(_debugChannel, "Invalid type for param " + param + ". Expected " + t.ToString() + ". Got Value: " + strVal); return; } } dicParams.Add(param, paramVal); } if (nfunc.ReturnType == typeof(void)) nfunc.Invoke(dicParams); else if (nfunc.ReturnType == typeof(IXPFile)) { IXPFile file = (IXPFile)nfunc.Invoke(dicParams); arg1.Send(Encoding.UTF8.GetBytes(file.XML)); } else { object response = nfunc.Invoke(dicParams); IXPFile iresponse = new IXPFile(); iresponse.NetworkFunction = ixp.NetworkFunction; iresponse.PutInfo("Response", response.ToString()); arg1.Send(Encoding.UTF8.GetBytes(iresponse.XML)); } }
public static void UpdateAlarmTime(this Client client, Alarm alarm) { IXPFile file = new IXPFile(); file.NetworkFunction = "com.projectgame.clock.alarm.setalarmtime"; file.PutInfo("alarm_id", "" + alarm.ID); file.PutInfo("hours", "" + alarm.Hours); file.PutInfo("minutes", "" + alarm.Minutes); file.PutInfo("seconds", "" + alarm.Seconds); client.NoResponseRequest(file); }
private static void CallTimer(Timer timer) { _clientSemaphore.Enqueue(); Debug.Log(_debugChannel, "Calling timer " + timer.Name); foreach(ServerInstance instance in _clients.Keys){ IXPFile file = new IXPFile(); file.NetworkFunction = _clients[instance][Function.CALLED]; file.PutInfo("timer_id", "" + timer.ID); file.PutInfo("name", "" + timer.Name); instance.Send(Encoding.UTF8.GetBytes(file.XML)); } _clientSemaphore.Dequeue(); }
private static void CallAlarm(Alarm alarm) { _clientSemaphore.Enqueue(); Debug.Log(_debugChannel, "Calling alarm " + alarm.Name); foreach(ServerInstance client in _clients.Keys) { IXPFile file = new IXPFile(); file.NetworkFunction = _clients[client]; file.PutInfo("alarm_id", "" + alarm.ID); file.PutInfo("name", "" + alarm.Name); client.Send(Encoding.UTF8.GetBytes(file.XML)); } _clientSemaphore.Dequeue(); }
public static void StartTimer(Timer timer) { _timers.Add (timer, new TimeSpan(timer.Hours, timer.Minutes, timer.Seconds)); foreach(ServerInstance instance in _clients.Keys){ IXPFile file = new IXPFile(); file.NetworkFunction = _clients[instance][Function.STARTED]; file.PutInfo("timer_id", "" + timer.ID); file.PutInfo("name", "" + timer.Name); instance.Send(Encoding.UTF8.GetBytes(file.XML)); } }
public IXPFile NetworkGetAlarm(int alarm_id) { IXPFile response = new IXPFile(); response.NetworkFunction = "com.projectgame.clock.alarm.getalarm"; Alarm alarm = AlarmDbConnector.GetAlarm(alarm_id); response.PutInfo("id", "" + alarm.ID); response.PutInfo("name", "" + alarm.Name); response.PutInfo("hours", "" + alarm.Hours); response.PutInfo("minutes", "" + alarm.Minutes); response.PutInfo("seconds", "" + alarm.Seconds); response.PutInfo("mon", alarm.Mon ? "TRUE" : "FALSE"); response.PutInfo("tue", alarm.Tue ? "TRUE" : "FALSE"); response.PutInfo("wed", alarm.Wed ? "TRUE" : "FALSE"); response.PutInfo("thu", alarm.Thu ? "TRUE" : "FALSE"); response.PutInfo("fri", alarm.Fri ? "TRUE" : "FALSE"); response.PutInfo("sat", alarm.Sat ? "TRUE" : "FALSE"); response.PutInfo("sun", alarm.Sun ? "TRUE" : "FALSE"); response.PutInfo("enabled", alarm.Enabled ? "TRUE" : "FALSE"); return response; }