public void UpdateSilent(string key, OMVSD.OSD value) { InternalUpdate(key, value); }
// updates and returns true if the value changed private bool InternalUpdate(string key, OMVSD.OSD value) { bool ret = false; lock (m_params) { if (m_params.ContainsKey(key.ToLower())) { m_params[key.ToLower()] = value; ret = true; } } return ret; }
public void Add(string key, OMVSD.OSD value) { string lkey = key.ToLower(); lock (m_params) { if (m_params.ContainsKey(lkey)) { m_params.Remove(lkey); } m_params.Add(lkey, value); } }
public void Update(string key, OMVSD.OSD value) { if (InternalUpdate(key, value)) { if (OnModifiedCallback != null) OnModifiedCallback(this, key, value); } }
private OMVSD.OSDMap PostActionLogout(OMVSD.OSD body) { OMVSD.OSDMap ret = new OMVSD.OSDMap(); m_comm.Disconnect(); return ret; }
private OMVSD.OSDMap PostActionTeleport(OMVSD.OSD body) { OMVSD.OSDMap ret = new OMVSD.OSDMap(); ParameterSet loginParams = new ParameterSet(); try { OMVSD.OSDMap paramMap = (OMVSD.OSDMap)body; string dest = paramMap["DESTINATION"].AsString(); m_log.Log(LogLevel.DCOMMDETAIL, "Request to teleport to {0}", dest); m_comm.DoTeleport(dest); } catch (Exception e) { m_log.Log(LogLevel.DBADERROR, "CONNECT EXCEPTION: " + e.ToString()); ret.Add(RestHandler.RESTREQUESTERRORCODE, new OMVSD.OSDInteger(1)); ret.Add(RestHandler.RESTREQUESTERRORMSG, new OMVSD.OSDString("Connection threw exception: " + e.ToString())); return ret; } return ret; }
private OMVSD.OSDMap PostActionExit(OMVSD.OSD body) { OMVSD.OSDMap ret = new OMVSD.OSDMap(); LGB.KeepRunning = false; return ret; }
private OMVSD.OSDMap PostActionLogin(OMVSD.OSD body) { OMVSD.OSDMap ret = new OMVSD.OSDMap(); ParameterSet loginParams = new ParameterSet(); try { OMVSD.OSDMap paramMap = (OMVSD.OSDMap)body; loginParams.Add(CommLLLP.FIELDFIRST, paramMap["LOGINFIRST"].AsString()); loginParams.Add(CommLLLP.FIELDLAST, paramMap["LOGINLAST"].AsString()); loginParams.Add(CommLLLP.FIELDPASS, paramMap["LOGINPASS"].AsString()); loginParams.Add(CommLLLP.FIELDGRID, paramMap["LOGINGRID"].AsString()); loginParams.Add(CommLLLP.FIELDSIM, paramMap["LOGINSIM"].AsString()); } catch { m_log.Log(LogLevel.DBADERROR, "MISFORMED POST REQUEST: "); ret.Add(RestHandler.RESTREQUESTERRORCODE, new OMVSD.OSDInteger(1)); ret.Add(RestHandler.RESTREQUESTERRORMSG, new OMVSD.OSDString("Misformed POST request")); return ret; } try { if (!m_comm.Connect(loginParams)) { m_log.Log(LogLevel.DBADERROR, "CONNECT FAILED"); ret.Add(RestHandler.RESTREQUESTERRORCODE, new OMVSD.OSDInteger(1)); ret.Add(RestHandler.RESTREQUESTERRORMSG, new OMVSD.OSDString("Could not log in")); return ret; } } catch (Exception e) { m_log.Log(LogLevel.DBADERROR, "CONNECT EXCEPTION: " + e.ToString()); ret.Add(RestHandler.RESTREQUESTERRORCODE, new OMVSD.OSDInteger(1)); ret.Add(RestHandler.RESTREQUESTERRORMSG, new OMVSD.OSDString("Connection threw exception: " + e.ToString())); return ret; } return ret; }
public OMVSD.OSD ProcessPostParam(RestHandler handler, Uri uri, string afterString, OMVSD.OSD rawbody) { OMVSD.OSD ret = new OMVSD.OSDMap(); try { OMVSD.OSDMap body = (OMVSD.OSDMap)rawbody; foreach (string akey in body.Keys) { if (handler.m_parameterSet.HasParameter(akey)) { handler.m_parameterSet.Update(akey, body[akey]); } } ret = handler.m_parameterSet.GetDisplayable(); } catch (Exception e) { m_log.Log(LogLevel.DREST, "Failed setting param in POST: {0}", e); } return ret; }
/// <summary> /// Posting to this communication instance. The URI comes in as "/api/MYNAME/ACTION" where /// ACTION is "login", "logout". /// </summary> /// <param name="uri"></param> /// <param name="body"></param> /// <returns></returns> public OMVSD.OSD ProcessPost(RestHandler handler, Uri uri, string after, OMVSD.OSD body) { OMVSD.OSDMap ret = new OMVSD.OSDMap(); if (m_comm == null) { m_log.Log(LogLevel.DBADERROR, "POST WITHOUT COMM CONNECTION!! URL=" + uri.ToString()); return new OMVSD.OSD(); } m_log.Log(LogLevel.DCOMMDETAIL, "Post action: {0}", uri.ToString()); switch (after) { case "/login": ret = PostActionLogin(body); break; case "/teleport": ret = PostActionTeleport(body); break; case "/logout": ret = PostActionLogout(body); break; case "/exit": ret = PostActionExit(body); break; default: m_log.Log(LogLevel.DBADERROR, "UNKNOWN ACTION: " + uri.ToString()); ret.Add(RestHandler.RESTREQUESTERRORCODE, new OMVSD.OSDInteger(1)); ret.Add(RestHandler.RESTREQUESTERRORMSG, new OMVSD.OSDString("Unknown action")); break; } return ret; }
private OMVSD.OSD PostHandler(RestHandler handler, Uri uri, String after, OMVSD.OSD body) { try { OMVSD.OSDMap mapBody = (OMVSD.OSDMap)body; m_log.Log(LogLevel.DCOMMDETAIL, "PostHandler: received chat '{0}'", mapBody["Message"]); // collect parameters and send it to the simulator string msg = Uri.UnescapeDataString(mapBody["Message"].AsString().Replace("+", " ")); OMVSD.OSD channelString = new OMVSD.OSDString("0"); mapBody.TryGetValue("Channel", out channelString); int channel = Int32.Parse(channelString.AsString()); OMVSD.OSD typeString = new OMVSD.OSDString("Normal"); mapBody.TryGetValue("Type", out typeString); OMV.ChatType chatType = OpenMetaverse.ChatType.Normal; if (typeString.AsString().Equals("Whisper")) chatType = OMV.ChatType.Whisper; if (typeString.AsString().Equals("Shout")) chatType = OMV.ChatType.Shout; m_comm.GridClient.Self.Chat(msg, channel, chatType); // echo my own message back for the log and chat window /* NOTE: Don't have to do this. The simulator echos it back OMV.ChatEventArgs cea = new OpenMetaverse.ChatEventArgs(m_comm.GridClient.Network.CurrentSim, msg, OpenMetaverse.ChatAudibleLevel.Fully, chatType, OpenMetaverse.ChatSourceType.Agent, m_comm.GridClient.Self.Name, OMV.UUID.Zero, OMV.UUID.Zero, m_comm.GridClient.Self.RelativePosition); this.Self_ChatFromSimulator(this, cea); */ } catch (Exception e) { m_log.Log(LogLevel.DCOMM, "ERROR PARSING CHAT MESSAGE: {0}", e); } // the return value does not matter return new OMVSD.OSDMap(); }
// Note that this does not do the update event thing public void UpdateSilent(string key, OMVSD.OSD value) { if (m_overrideParams.HasParameter(key)) { m_overrideParams.Update(key, value); return; } else if (m_userParams.HasParameter(key)) { m_userParams.Update(key, value); return; } else if (m_iniParams.HasParameter(key)) { m_iniParams.Update(key, value); return; } }
public void Update(string key, OMVSD.OSD value) { UpdateSilent(key, value); }
public void Add(string key, OMVSD.OSD value) { // TODO: }
private OMVSD.OSD PostHandler(RestHandler handler, Uri uri, String after, OMVSD.OSD body) { return new OMVSD.OSDMap(); }