Example #1
0
        private void saveSessionArchiveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                OSDMap map = new OSDMap(1);
                OSDArray sessionArray = new OSDArray();

                foreach (Session item in m_SessionViewItems)
                {
                    OSDMap session = new OSDMap();
                    session["type"] = OSD.FromString(item.GetType().Name);
                    session["tag"] = OSD.FromBinary(item.Serialize());
                    sessionArray.Add(session);
                }

                map["sessions"] = sessionArray;

                try
                {
                    File.WriteAllText(saveFileDialog1.FileName, map.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred trying to save session archive: " + ex);
                }
            }
        }
        private void saveSessionArchiveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                OSDMap map = new OSDMap(1);
                OSDArray sessionArray = new OSDArray();
                foreach (ListViewItem item in listViewSessions.Items)
                {
                    if (item.Tag is Session)
                    {
                        Session data = null;
                        if (item.Tag is SessionCaps)
                        {
                            data = (SessionCaps)item.Tag;
                        }
                        else if (item.Tag is SessionEvent)
                        {
                            data = (SessionEvent)item.Tag;
                        }
                        else if (item.Tag is SessionLogin)
                        {
                            data = (SessionLogin)item.Tag;
                        }
                        else if (item.Tag is SessionPacket)
                        {
                            data = (SessionPacket)item.Tag;
                        }
                        else
                        {
                            Console.WriteLine("Not a valid session type?");
                            continue;
                        }
                        //Type t = item.Tag.GetType();

                        //Session data = (SessionCaps)item.Tag;
                        OSDMap session = new OSDMap();
                        //session["name"] = OSD.FromString(item.Name);
                        //session["image_index"] = OSD.FromInteger(item.ImageIndex);
                        session["id"] = OSD.FromString(item.SubItems[0].Text);
                        //session["protocol"] = OSD.FromString(item.SubItems[1].Text);
                        //session["packet"] = OSD.FromString(item.SubItems[2].Text);
                        //session["size"] = OSD.FromString(item.SubItems[3].Text);
                        //session["host"] = OSD.FromString(item.SubItems[4].Text);
                        session["type"] = OSD.FromString(data.GetType().ToString());
                        session["tag"] = OSD.FromBinary(data.Serialize());
                        sessionArray.Add(session);
                    }
                }

                map["sessions"] = sessionArray;

                try
                {
                    File.WriteAllText(saveFileDialog1.FileName, map.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred trying to save session archive: " + ex);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Process any incoming events, check to see if we have a message created for the event, 
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="body"></param>
        private void EventQueueEventHandler(string eventName, OSDMap body)
        {
            IMessage message = Messages.MessageUtils.DecodeEvent(eventName, body);
            if (message != null)
            {
                Simulator.Client.Network.CapsEvents.BeginRaiseEvent(eventName, message, Simulator);

                #region Stats Tracking
                if (Simulator.Client.Settings.TRACK_UTILIZATION)
                {
                    Simulator.Client.Stats.Update(eventName, OpenMetaverse.Stats.Type.Message, 0, body.ToString().Length);
                }
                #endregion
            }
            else
            {
                Logger.Log("No Message handler exists for event " + eventName + ". Unable to decode. Will try Generic Handler next", Helpers.LogLevel.Warning);
                Logger.Log("Please report this information to http://jira.openmetaverse.org/: \n" + body, Helpers.LogLevel.Debug);

                // try generic decoder next which takes a caps event and tries to match it to an existing packet
                if (body.Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)body;
                    Packet packet = Packet.BuildPacket(eventName, map);
                    if (packet != null)
                    {
                        NetworkManager.IncomingPacket incomingPacket;
                        incomingPacket.Simulator = Simulator;
                        incomingPacket.Packet = packet;

                        Logger.DebugLog("Serializing " + packet.Type.ToString() + " capability with generic handler", Simulator.Client);

                        Simulator.Client.Network.PacketInbox.Enqueue(incomingPacket);
                    }
                    else
                    {
                        Logger.Log("No Packet or Message handler exists for " + eventName, Helpers.LogLevel.Warning);
                    }
                }
            }
        }
        //public override string ToXml(Direction direction)
        //{
        //    if (direction == this.Direction)
        //        return Packet.ToXmlString(this.Packet);
        //    else
        //        return base.ToXml(direction);
        //}
        //public override string ToStringNotation(Direction direction)
        //{
        //    if (direction == this.Direction)
        //        return Packet.GetLLSD(this.Packet).ToString();
        //    else
        //        return base.ToStringNotation(direction);
        //}
        public override byte[] Serialize()
        {
            OSDMap map = new OSDMap(5);
            map["Name"] = OSD.FromString(this.Name);
            map["Host"] = OSD.FromString(this.Host);
            map["PacketBytes"] = OSD.FromBinary(this.Packet.ToBytes());
            map["Direction"] = OSD.FromInteger((int)this.Direction);
            map["ContentType"] = OSD.FromString(this.ContentType);

            return OpenMetaverse.Utils.StringToBytes(map.ToString());
        }
        public override byte[] Serialize()
        {
            OSDMap map = new OSDMap(6);
            map["Name"] = OSD.FromString(this.Name);
            map["Host"] = OSD.FromString(this.Host);
            map["Data"] = OSD.FromString(this.Data.ToString());
            map["Direction"] = OSD.FromInteger((int)this.Direction);
            map["ContentType"] = OSD.FromString(this.ContentType);
            map["Protocol"] = OSD.FromString(this.Protocol);

            return OpenMetaverse.Utils.StringToBytes(map.ToString());
        }
        public override byte[] Serialize()
        {
            OSDMap map = new OSDMap(7);
            map["Name"] = OSD.FromString(this.Name);
            map["Host"] = OSD.FromString(this.Host);
            map["ResponseBytes"] = OSD.FromBinary(this.ResponseBytes);
            map["Direction"] = OSD.FromInteger((int)this.Direction);
            map["ContentType"] = OSD.FromString(this.ContentType);
            map["Protocol"] = OSD.FromString(this.Protocol);

            OSDArray responseHeadersArray = new OSDArray();
            foreach (String key in this.ResponseHeaders.Keys)
            {
                OSDMap rMap = new OSDMap(1);
                rMap[key] = OSD.FromString(this.ResponseHeaders[key]);
                responseHeadersArray.Add(rMap);
            }
            map["ResponseHeaders"] = responseHeadersArray;

            return Utils.StringToBytes(map.ToString());
        }
Example #7
0
       /// <summary>
       /// Start a friends confrence
       /// </summary>
       /// <param name="participants"><seealso cref="UUID"/> List of UUIDs to start a confrence with</param>
       /// <param name="tmp_session_id"><seealso cref="UUID"/>a Unique UUID that will be returned in the OnJoinedGroupChat callback></param>
       public void StartIMConfrence(List <UUID> participants,UUID tmp_session_id)
       {
           if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
               throw new Exception("ChatSessionRequest capability is not currently available");

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("ChatSessionRequest");

            if (url != null)
            {
                OSDMap req = new OSDMap();
                req.Add("method", OSD.FromString("start conference"));
                OSDArray members = new OSDArray();
                foreach(UUID participant in participants)
                    members.Add(OSD.FromUUID(participant));

                req.Add("params",members);
                req.Add("session-id", OSD.FromUUID(tmp_session_id));

                byte[] postData = StructuredData.OSDParser.SerializeLLSDXmlBytes(req);

                Console.WriteLine(req.ToString());

                CapsClient request = new CapsClient(url);
                request.StartRequest(postData);
            }
            else
            {
                throw new Exception("ChatSessionRequest capability is not currently available");
            }
        }
Example #8
0
        private void saveSessionArchiveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                OSDMap map = new OSDMap(1);
                OSDArray sessionArray = new OSDArray();
                foreach (ListViewItem item in listViewSessions.Items)
                {
                    if (item.Tag is Packet || item.Tag is IMessage || item.Tag is String || item.Tag is CapsRequest)
                    {
                        OSDMap session = new OSDMap();
                        session["name"] = OSD.FromString(item.Name);
                        session["image_index"] = OSD.FromInteger(item.ImageIndex);
                        session["id"] = OSD.FromString(item.SubItems[0].Text);
                        session["protocol"] = OSD.FromString(item.SubItems[1].Text);
                        session["packet"] = OSD.FromString(item.SubItems[2].Text);
                        session["size"] = OSD.FromString(item.SubItems[3].Text);
                        session["host"] = OSD.FromString(item.SubItems[4].Text);

                        if (item.Tag is Packet)
                        {
                            session["tag"] = OSD.FromBinary(Utils.StringToBytes(DecodePacket.PacketToString((Packet)item.Tag)));
                        }
                        else if (item.Tag is IMessage)
                        {
                            IMessage m = (IMessage)item.Tag;
                            session["tag"] = OSD.FromBinary(Utils.StringToBytes(m.Serialize().ToString()));
                        }
                        else if (item.Tag is System.String)
                        {
                            session["tag"] = OSD.FromBinary(Utils.StringToBytes(Tag.ToString()));
                        }
                        else
                        {
                            // we intentionally don't save login requests or responses
                            session["tag"] = OSD.FromBinary(Utils.StringToBytes("Encoding disabled for this item type"));
                        }

                        sessionArray.Add(session);
                    }
                }

                map["sessions"] = sessionArray;

                try
                {
                    File.WriteAllText(saveFileDialog1.FileName, map.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred trying to save session archive: " + ex);
                }
            }
        }
        /// <summary>
        /// Convert active connections information to JSON string. Returns a structure:
        /// <pre>
        /// {"regionName": {
        ///     "presenceName": {
        ///         "name": "presenceName",
        ///         "position": "<x,y,z>",
        ///         "isRoot": "false",
        ///         "throttle": {
        ///         },
        ///         "queue": {
        ///         }
        ///     },
        ///     ... // multiple presences in the scene
        ///   },
        ///   ...   // multiple regions in the sim
        /// }
        ///
        /// </pre>
        /// </summary>
        /// <param name="pModelResult"></param>
        /// <returns></returns>
        public string RenderJson(Hashtable pModelResult)
        {
            List<Scene> all_scenes = (List<Scene>) pModelResult["hdata"];

            OSDMap regionInfo = new OSDMap();
            foreach (Scene scene in all_scenes)
            {
                OSDMap sceneInfo = new OpenMetaverse.StructuredData.OSDMap();
                List<ScenePresence> avatarInScene = scene.GetScenePresences();
                foreach (ScenePresence av in avatarInScene)
                {
                    OSDMap presenceInfo = new OSDMap();
                    presenceInfo.Add("Name", new OSDString(av.Name));

                    Dictionary<string,string> queues = new Dictionary<string, string>();
                    if (av.ControllingClient is IStatsCollector)
                    {
                        IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
                        queues = decodeQueueReport(isClient.Report());
                    }
                    OSDMap queueInfo = new OpenMetaverse.StructuredData.OSDMap();
                    foreach (KeyValuePair<string, string> kvp in queues) {
                        queueInfo.Add(kvp.Key, new OSDString(kvp.Value));
                    }
                    sceneInfo.Add("queues", queueInfo);

                    if (av.IsChildAgent)
                        presenceInfo.Add("isRoot", new OSDString("false"));
                    else
                        presenceInfo.Add("isRoot", new OSDString("true"));

                    if (av.AbsolutePosition == DefaultNeighborPosition)
                    {
                        presenceInfo.Add("position", new OSDString("<0, 0, 0>"));
                    }
                    else
                    {
                        presenceInfo.Add("position", new OSDString(string.Format("<{0},{1},{2}>",
                                                    (int)av.AbsolutePosition.X,
                                                    (int) av.AbsolutePosition.Y,
                                                    (int) av.AbsolutePosition.Z)) );
                    }

                    Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
                    OSDMap throttleInfo = new OpenMetaverse.StructuredData.OSDMap();
                    foreach (string throttlename in throttles.Keys)
                    {
                        throttleInfo.Add(throttlename, new OSDString(throttles[throttlename].ToString()));
                    }
                    presenceInfo.Add("throttle", throttleInfo);

                    sceneInfo.Add(av.Name, presenceInfo);
                }
                regionInfo.Add(scene.RegionInfo.RegionName, sceneInfo);
            }
            return regionInfo.ToString();
        }