private void DoMove(RequestData rdata) { if (rdata.Parameters.Length < 6) { Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId); rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided"); } else { string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE); ScenePresence presence = null; Scene scene = null; if (names.Length != 2) { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("invalid avatar name: <{0}>", rdata.Parameters[PARM_MOVE_AVATAR])); } Rest.Log.WarnFormat("{0} '{1}' command received for {2} {3}", MsgId, rdata.Parameters[0], names[0], names[1]); // The first parameter should be an avatar name, look for the // avatar in the known regions first. Rest.main.SceneManager.ForEachScene(delegate(Scene s) { s.ForEachScenePresence(delegate(ScenePresence sp) { if (sp.Firstname == names[0] && sp.Lastname == names[1]) { scene = s; presence = sp; } }); }); if (presence != null) { Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}", MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName); try { float x = Convert.ToSingle(rdata.Parameters[PARM_MOVE_X]); float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); Vector3 vector = new Vector3(x, y, z); presence.DoAutoPilot(0, vector, presence.ControllingClient); } catch (Exception e) { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("invalid parameters: {0}", e.Message)); } } else { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("avatar {0} not present", rdata.Parameters[PARM_MOVE_AVATAR])); } rdata.Complete(); rdata.Respond("OK"); } }
private void DoMove(RequestData rdata) { if (rdata.Parameters.Length < 6) { Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId); rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided"); } else { string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE); ScenePresence presence = null; Scene scene = null; if (names.Length != 2) { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("invalid avatar name: <{0}>",rdata.Parameters[PARM_MOVE_AVATAR])); } Rest.Log.WarnFormat("{0} '{1}' command received for {2} {3}", MsgId, rdata.Parameters[0], names[0], names[1]); // The first parameter should be an avatar name, look for the // avatar in the known regions first. Rest.main.SceneManager.ForEachScene(delegate(Scene s) { s.ForEachScenePresence(delegate(ScenePresence sp) { if (sp.Firstname == names[0] && sp.Lastname == names[1]) { scene = s; presence = sp; } }); }); if (presence != null) { Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}", MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName); try { float x = Convert.ToSingle(rdata.Parameters[PARM_MOVE_X]); float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); Vector3 vector = new Vector3(x,y,z); presence.DoAutoPilot(0,vector,presence.ControllingClient); } catch (Exception e) { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("invalid parameters: {0}", e.Message)); } } else { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("avatar {0} not present", rdata.Parameters[PARM_MOVE_AVATAR])); } rdata.Complete(); rdata.Respond("OK"); } }
private void DoHelp(RequestData rdata) { rdata.body = Help; rdata.Complete(); rdata.Respond("Help"); }