コード例 #1
0
    /// <summary>
    /// take the focused object and
    /// adds the line renderer to that object.
    /// if trash is true, removes the linerenderer from the object and
    /// remove the object from the list
    /// </summary>
    private void CreateLineRenderer(MsgEntry me)
    {
        Vector3    camera = new Vector3(me.Pr[0], me.Pr[1], me.Pr[2]);
        ObjectInfo info   = me.Info;

        //populate serializable
        Information newInfo = new Information();

        newInfo.objectName = info.ObjType;
        newInfo.posx       = me.Pr[0];
        newInfo.posy       = me.Pr[1];
        newInfo.posz       = me.Pr[2];
        objInformation.Add(newInfo);
        //end

        //meObject obj = GameObject.Find(info.ObjType);
        try
        {
            GameObject obj = GameObject.Find(info.ObjType);
            //Debug.Log(obj);
            obj.AddComponent <LineRenderer>();
            LineRenderer lr = obj.GetComponent <LineRenderer>();
            lr.SetPosition(0, camera);
            lr.SetPosition(1, obj.transform.position);
            lr.material = lineRenderer.material;
            lr.SetWidth(.01f, .01f);
            lr.enabled = false;
            //add the object to the list og gameobjects
            objList.Add(obj);
        }
        catch (Exception e)
        {
            Debug.Log(e);
        }
    }
コード例 #2
0
    /// <summary>
    /// creates the message to be sent to the server
    /// </summary>
    void CreateMessage()
    {
        ObjectInfo info = new ObjectInfo();

        info.ObjType = focused.name;
        //create message entry
        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = showObject.ShowId;
        //add the camera's current position
        entry.Pr.Add(mainCamera.transform.position.x);
        entry.Pr.Add(mainCamera.transform.position.y);
        entry.Pr.Add(mainCamera.transform.position.z);
        //add the focused object position
        entry.Pr.Add(focused.transform.position.x);
        entry.Pr.Add(focused.transform.position.y);
        entry.Pr.Add(focused.transform.position.z);
        //add the name of the focusedObject
        entry.Info = info;
        //create sync message
        SyncMsg msg = new SyncMsg();

        msg.MsgEntry.Add(entry);
        //send message
        cm.SendMessage(msg);
    }
コード例 #3
0
    /// <summary>
    /// draws the line from the focused object to
    /// the user's position frame by frame
    /// </summary>1
    private IEnumerator DrawLine(MsgEntry me)
    {
        Vector3 camera = new Vector3(me.Pr[0], me.Pr[1], me.Pr[2]);
        Vector3 obj    = new Vector3(me.Pr[3], me.Pr[4], me.Pr[5]);

        while (state)
        {
            yield return(new WaitForEndOfFrame());

            if (counter < dist)
            {
                counter += .1f / lineDrawSpeed;
                float x = Mathf.Lerp(0, dist, counter);

                Vector3 pointA          = camera;
                Vector3 pointB          = obj;
                Vector3 pointAngeleLine = x * Vector3.Normalize(pointB - pointA) + pointA;

                lineRenderer.SetPosition(1, pointAngeleLine);
            }
            else
            {
                state = false;
            }
        }
    }
コード例 #4
0
    private IEnumerator WaitForInit()
    {
        MEHoloEntrance entrance = MEHoloEntrance.Instance;

        while (!entrance.HasInit)
        {
            yield return(null);
        }

        collaborationManager = CollaborationManager.Instance;

        collaborationManager.AddMessageHandler(this);

        MsgEntry entry = new MsgEntry();

        entry.ShowId = "Test";
        GetTransformFloat(cube.transform, entry);

        ShowObject  showObject = new ShowObject(entry);
        SceneObject roomData   = new SceneObject();

        roomData.ShowObjectDic.Add(showObject.ShowId, showObject);

        collaborationManager.roomInitData = roomData;

        collaborationManager.TurnOn();
    }
コード例 #5
0
    /// <summary>
    /// receives the name of the focused object,
    /// searcesh the object in objList: remove linerenderer and removes object from the list
    /// </summary>
    /// <param name="me"></param>
    private void DeleteAction(MsgEntry me)
    {
        //extract from me the name of the focused object
        ObjectInfo info = me.Info;

        //iterate the list of objects with line renderer
        for (int i = objList.Count - 1; i >= 0; i--)
        {
            if (objList[i].name == info.ObjType)
            {
                LineRenderer lr = objList[i].GetComponent <LineRenderer>();
                //checl lr is not null the destroy it and remove object from the list
                if (lr != null)
                {
                    Destroy(lr);
                    objList.Remove(objList[i]);
                }
            }
        }

        //finds the object in the list to be serialide. Removes the object and then
        //save the list through SaveAction()
        for (int i = objInformation.Count - 1; i >= 0; i--)
        {
            if (info.ObjType == objInformation[i].objectName)
            {
                objInformation.Remove(objInformation[i]);
            }
        }
        SaveAction();
        trash = false;
    }
コード例 #6
0
    /// <summary>
    /// initialization of modules and variables
    /// </summary>
    /// <returns></returns>
    private IEnumerator WaitForInit()
    {
        MEHoloEntrance entrance = MEHoloEntrance.Instance;

        while (!entrance.HasInit)
        {
            yield return(null);
        }

        //instantiate elements
        inputManager           = MultiInputManager.Instance;
        inputManager.layerMask = LayerMask.GetMask("Default") | LayerMask.GetMask("UI");
        inputManager.cbTap    += OnTap;
        //collaboration module
        collaborationManager = CollaborationManager.Instance;
        collaborationManager.AddMessageHandler(this);
        collaborationManager.cbEnterRoom = cbEnterRoom;
        //cursor module
        cursor = UIManager.Instance.cursorController;

        //it is possible to use more than message.
        //bear in mind that messages must have different id so
        string   showId = "showId001";
        MsgEntry msg    = new MsgEntry();

        msg.ShowId = showId;
        showObject = new ShowObject(msg);
        roomData   = new SceneObject();
        roomData.ShowObjectDic.Add(showObject.ShowId, showObject);

        collaborationManager.roomInitData = roomData;
        collaborationManager.TurnOn();
    }
コード例 #7
0
ファイル: BinaryLogFormatter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Formats a log entry as a serialized representation.
 /// </summary>
 /// <remarks>
 /// Will use a BinaryFormatter for doing the actual serialization.
 /// </remarks>
 /// <param name="log">The <see cref="MsgEntry"/> to format.</param>
 /// <returns>A string version of the <see cref="MsgEntry"/> that can be deserialized back to a <see cref="MsgEntry"/> instance.</returns>
 public override string Format(MsgEntry log)
 {
     using (MemoryStream binaryStream = new MemoryStream())
     {
         GetFormatter().Serialize(binaryStream, log);
         return Convert.ToBase64String(binaryStream.ToArray());
     }
 }
コード例 #8
0
 public MsgChecker(int maxSize, float dupeTime)
 {
     _minDuplicateTime = dupeTime;
     _msgEntry         = new MsgEntry[maxSize];
     for (int i = 0; i < _msgEntry.Length; i++)
     {
         _msgEntry[i] = new MsgEntry();
     }
 }
コード例 #9
0
ファイル: XmlMsgFormatter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Formats the <see cref="MsgEntry"/> into an XML String representation.
 /// </summary>
 /// <param name="log">A MsgEntry or any sub class of it</param>
 /// <returns></returns>
 public override string Format(MsgEntry log)
 {
     StringBuilder result = new StringBuilder();
     using (XmlWriter writer = new XmlTextWriter(new StringWriter(result)))
     {
         Format(log, writer);
     }
     return result.ToString();
 }
コード例 #10
0
    private void initShowObject()
    {
        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = this.ShowId;
        entry.Vec.Add((long)m_behaviourType);
        m_showObject = new ShowObject(entry);
    }
コード例 #11
0
 private static void DisplayMessage(Connection con, MsgEntry msgEntry)
 {
     if (!Net.sv.write.Start())
     {
         return;
     }
     Net.sv.write.PacketID(Message.Type.Message);
     Net.sv.write.String(msgEntry.TopString);
     Net.sv.write.String(msgEntry.BottomString);
     Net.sv.write.Send(new SendInfo(con));
 }
コード例 #12
0
    public virtual MsgEntry CreateMsgEntry()
    {
        //MsgEntry entry = new MsgEntry(OP_TYPE.UPD, id, true, info, null, null);
        MsgEntry entry = new MsgEntry();

        entry.ShowId = id;
        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.Pr.Add(info);
        entry.Info.ObjType = type;
        return(entry);
    }
コード例 #13
0
    // Use this for initialization

    public void CreateObjectEntryData(Transform objectTrans, MsgEntry entry)
    {
        entry.ShowId = objectShowId;
        entry.Pr.Clear();
        float[] rs = new float[6];
        entry.Pr.Add(objectTrans.position.x);
        entry.Pr.Add(objectTrans.position.y);
        entry.Pr.Add(objectTrans.position.z);
        entry.Pr.Add(objectTrans.eulerAngles.x);
        entry.Pr.Add(objectTrans.eulerAngles.y);
        entry.Pr.Add(objectTrans.eulerAngles.z);
    }
コード例 #14
0
    private void GetTransformFloat(Transform trans, MsgEntry entry)
    {
        entry.Pr.Clear();

        float[] rs = new float[6];
        entry.Pr.Add(trans.position.x);
        entry.Pr.Add(trans.position.y);
        entry.Pr.Add(trans.position.z);
        entry.Pr.Add(trans.eulerAngles.x);
        entry.Pr.Add(trans.eulerAngles.y);
        entry.Pr.Add(trans.eulerAngles.z);
    }
コード例 #15
0
    public override MsgEntry CreateMsgEntry()
    {
        UpdateData();
        this.id = this.cv.containerType.ToString();
        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = id;
        entry.Pr.Add(info);
        entry.Info         = new ObjectInfo();
        entry.Info.ObjType = GetObjectType();
        return(entry);
    }
コード例 #16
0
    public MsgEntry CreateMsgEntry()
    {
        UpdateData();
        this.id = this.GetObjectType();
        //MsgEntry entry = new MsgEntry(OP_TYPE.UPD, id, true, info, null, null);
        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = id;
        entry.Pr.Add(info);
        entry.Info.ObjType = GetObjectType();
        return(entry);
    }
コード例 #17
0
    /// <summary>
    /// processes the messages
    /// </summary>
    /// <param name="proto"></param>
    void DealMessage(SyncProto proto)
    {
        Google.Protobuf.Collections.RepeatedField <MsgEntry> messages = proto.SyncMsg.MsgEntry;
        //Debug.Log("deal message");
        if (messages == null)
        {
            return;
        }
        for (int i = 0; i < messages.Count; i++)
        {
            MsgEntry msgEntry = messages[i];
            if (msgEntry.ShowId == showObject.ShowId)
            {
                //ChangeCubeColor((ColorType)((int)msgEntry.Vec[0]));
                Debug.Log("I am deal message");
            }
            if (msgEntry.ShowId == "000")
            {
                string s         = msgEntry.Info.ToString();
                string ipAddress = s.Substring(14, collaborationManager.clientId.Length);
                //the devices' IP are extracted and inserted in idList
                //the ip is used to diversify clearly one player to the other
                idList.Add(ipAddress);
            }

            if (msgEntry.ShowId == playerA.id)
            {
                string s    = msgEntry.Info.ToString();
                string cell = s.Substring(14, 5);
                //Debug.Log(cell);
                ChangeCubeColor((CType)((int)msgEntry.Vec[0]), cell, msgEntry.Pr[0]);
                NoWinner(msgEntry.Pr[1]);
            }

            if (msgEntry.ShowId == playerB.id)
            {
                string s    = msgEntry.Info.ToString();
                string cell = s.Substring(14, 5);
                ChangeCubeColor((CType)((int)msgEntry.Vec[0]), cell, msgEntry.Pr[0]);
                NoWinner(msgEntry.Pr[1]);
            }

            if (msgEntry.ShowId == "001")
            {
                string s = msgEntry.Info.ToString();
                waiting = s.Substring(14, collaborationManager.clientId.Length);
                Debug.Log("Waiting is :" + waiting);
                VerifyCurrentPlayer(waiting);
            }
        }
    }
コード例 #18
0
    public UnetObjectInfo()
    {
        ObjectInfo info = new ObjectInfo
        {
            ObjType = this.objectType
        };

        objectEntry = new MsgEntry
        {
            OpType = MsgEntry.Types.OP_TYPE.Upd,
            ShowId = objectShowId
        };
        objectEntry.Vec.Add((long)objectBehavior);
    }
コード例 #19
0
        private void DisplayQueueMessage(Connection con, MsgEntry msgEntry)
        {
            if (!Net.sv.write.Start())
            {
                return;
            }
            var ahead  = GetQueuePosition(con);
            var behind = (ServerMgr.Instance.connectionQueue.Queued - ahead) - 1;

            Net.sv.write.PacketID(Message.Type.Message);
            Net.sv.write.String(msgEntry.TopString);
            Net.sv.write.String(msgEntry.BottomString.Replace("{AHEAD}", ahead.ToString()).Replace("{BEHIND}", behind.ToString()));
            Net.sv.write.Send(new SendInfo(con));
        }
コード例 #20
0
    public MsgEntry CreateMsgEntry()
    {
        UpdateData();
        //Debug.Log("animationstarttime:" + info[3]);
        this.id = this.GetObjectType();
        // MsgEntry entry = new MsgEntry(OP_TYPE.UPD, id, true, info, null, null);

        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = id;
        entry.Pr.Add(info);
        entry.Info         = new ObjectInfo();
        entry.Info.ObjType = GetObjectType();
        return(entry);
    }
コード例 #21
0
    /// <summary>
    /// creates the message to be sent to the server.
    /// Content: device Ip
    /// </summary>
    void PlayAction()
    {
        MsgEntry msgEntry = new MsgEntry();

        msgEntry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        msgEntry.ShowId = "000";
        ObjectInfo info = new ObjectInfo();

        info.ObjType  = collaborationManager.clientId;
        msgEntry.Info = info;

        SyncMsg msg = new SyncMsg();

        msg.MsgEntry.Add(msgEntry);
        collaborationManager.SendMessage(msg);
    }
コード例 #22
0
    /// <summary>
    /// creates a message that contains
    /// the waiting player id
    /// </summary>
    void WaitingPlayerMessage(string currPlayer)
    {
        MsgEntry msgEntry = new MsgEntry();

        msgEntry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        msgEntry.ShowId = "001";
        ObjectInfo info = new ObjectInfo();

        info.ObjType  = currPlayer;
        msgEntry.Info = info;

        SyncMsg msg = new SyncMsg();

        msg.MsgEntry.Add(msgEntry);
        collaborationManager.SendMessage(msg);
    }
コード例 #23
0
    /// <summary>
    /// manages the color of the cell according to the player that clicks it
    /// </summary>
    /// <param name="ip"></param>
    private void ClickCube(string ip, string cellname, float cellcount)
    {
        if (ip == playerA.id)
        {
            CurrentColor = 0;
            blueCounter += 1;
            if (blueCounter > 3)
            {
                blueSelection.Clear();
                blueCounter = 1;
            }

            counter = blueCounter;
        }

        if (ip == playerB.id)
        {
            CurrentColor  = CType.green;
            greenCounter += 1;
            if (greenCounter > 3)
            {
                greenSelection.Clear();
                greenCounter = 1;
            }

            counter = greenCounter;
        }

        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = ip;
        ObjectInfo info = new ObjectInfo();

        info.ObjType = cellname;
        entry.Info   = info;
        entry.Pr.Add(counter);
        entry.Pr.Add(cellcount);
        entry.Vec.Add((long)CurrentColor);

        SyncMsg msg = new SyncMsg();

        msg.MsgEntry.Add(entry);

        collaborationManager.SendMessage(msg);
    }
コード例 #24
0
    public void DealMessage(SyncProto proto)
    {
        Google.Protobuf.Collections.RepeatedField <MsgEntry> messages = proto.SyncMsg.MsgEntry;
        if (messages == null)
        {
            return;
        }

        for (int i = 0; i < messages.Count; i++)
        {
            MsgEntry msg = messages[i];
            cube.transform.position    = new Vector3(msg.Pr[0], msg.Pr[1], msg.Pr[2]);
            cube.transform.eulerAngles = new Vector3(msg.Pr[3], msg.Pr[4], msg.Pr[5]);

            Debug.Log("Receive Message! " + msg.Pr);
        }
    }
コード例 #25
0
 void DealMessage(SyncProto proto)
 {
     Google.Protobuf.Collections.RepeatedField <MsgEntry> messages = proto.SyncMsg.MsgEntry;
     //Debug.Log("deal message");
     if (messages == null)
     {
         return;
     }
     for (int i = 0; i < messages.Count; i++)
     {
         MsgEntry msgEntry = messages[i];
         if (msgEntry.ShowId == showObject.ShowId)
         {
             ChangeCubeColor((ColorType)((int)msgEntry.Vec[0]));
         }
     }
 }
コード例 #26
0
    void Update()
    {
        if (collaborationManager != null)
        {
            if (collaborationManager.enterRoomResult == EnterRoomResult.EnterRoomSuccess)
            {
                MsgEntry entry = new MsgEntry();
                entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
                entry.ShowId = "Test";
                GetTransformFloat(cube.transform, entry);

                SyncMsg msg = new SyncMsg();
                msg.MsgEntry.Add(entry);

                collaborationManager.SendMessage(msg);
            }
        }
    }
コード例 #27
0
    /// <summary>
    /// creates a message that is bound to be use only
    /// when trash button is selected
    /// </summary>
    void CreateTrashMessage()
    {
        ObjectInfo info = new ObjectInfo();

        info.ObjType = focused.name;
        //create message entry
        MsgEntry entry = new MsgEntry();

        entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
        entry.ShowId = "showId002";
        //add the name of the focused Object
        entry.Info = info;
        //create Sync message
        SyncMsg msg = new SyncMsg();

        msg.MsgEntry.Add(entry);
        cm.SendMessage(msg);
    }
コード例 #28
0
    public void RefreshObjectEntryData(Transform trans, SyncProto proto)
    {
        Google.Protobuf.Collections.RepeatedField <MsgEntry> messages = proto.SyncMsg.MsgEntry;
        if (messages == null)
        {
            return;
        }

        for (int i = 0; i < messages.Count; i++)
        {
            MsgEntry msg = messages[i];
            if (msg.ShowId == this.objectShowId)
            {
                trans.position    = new Vector3(msg.Pr[0], msg.Pr[1], msg.Pr[2]);
                trans.eulerAngles = new Vector3(msg.Pr[3], msg.Pr[4], msg.Pr[5]);
            }
        }
    }
コード例 #29
0
 public void AdvanceMessage()
 {
     if (!_config.EnableCyclicity || Time.realtimeSinceStartup < _nextMessageChange)
     {
         return;
     }
     _nextMessageChange = Time.realtimeSinceStartup + _config.CyclicityFreq;
     if (_config.EnableRandomCyclicity)
     {
         CurrentMessage = PickRandom(MessagesList);
     }
     else
     {
         CurrentMessage = MessagesList[_messageIndex++];
         if (_messageIndex >= MessagesList.Count)
         {
             _messageIndex = 0;
         }
     }
 }
コード例 #30
0
        private void ClickCube()
        {
            CurrentColor += 1;
            if ((int)CurrentColor > 2)
            {
                CurrentColor = 0;
            }

            MsgEntry entry = new MsgEntry();

            entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
            entry.ShowId = showObject.ShowId;
            entry.Vec.Add((long)CurrentColor);

            SyncMsg msg = new SyncMsg();

            msg.MsgEntry.Add(entry);

            cm.SendMessage(msg);
        }
コード例 #31
0
ファイル: TokenFunction.cs プロジェクト: Ampy/Work
        /// <summary>
        /// Searches for token functions in the message and replace all with formatted values.
        /// </summary>
        /// <param name="messageBuilder">Message template containing tokens.</param>
        /// <param name="log">Log entry containing properties to format.</param>
        public virtual void Format(StringBuilder messageBuilder, MsgEntry log)
        {
            int pos = 0;
            while (pos < messageBuilder.Length)
            {
                string messageString = messageBuilder.ToString();
                if (messageString.IndexOf(this.startDelimiter) == -1)
                {
                    break;
                }

                string tokenTemplate = GetInnerTemplate(pos, messageString);
                string tokenToReplace = this.startDelimiter + tokenTemplate + this.endDelimiter;
                pos = messageBuilder.ToString().IndexOf(tokenToReplace);

                string tokenValue = FormatToken(tokenTemplate, log);

                messageBuilder.Replace(tokenToReplace, tokenValue);
            }
        }
コード例 #32
0
        private IEnumerator WaitForInit()
        {
            MEHoloEntrance entrance = MEHoloEntrance.Instance;

            while (!entrance.HasInit)
            {
                yield return(null);
            }

            cursor = UIManager.Instance.cursorController;


            // Todo: Begin your logic
            inputManager        = MultiInputManager.Instance;
            inputManager.cbTap += OnTap;

            cm = CollaborationManager.Instance;
            cm.AddMessageHandler(this);
            cm.cbEnterRoom = cbEnterRoom;

            string showId   = "showId001";
            string obj_type = "ColorType";

            MsgEntry msg = new MsgEntry();

            msg.ShowId = showId;

            ObjectInfo info = new ObjectInfo();

            info.ObjType = obj_type;
            msg.Info     = info;

            msg.Vec.Add((long)CurrentColor);

            showObject = new ShowObject(msg);
            roomData   = new SceneObject();
            roomData.ShowObjectDic.Add(showObject.ShowId, showObject);

            cm.roomInitData = roomData;
            cm.TurnOn();
        }
コード例 #33
0
    public void SelectOnePlanet(string name, System.Action cb = null, bool sendMsg = true, bool animating = true, float animationStartUniverseTime = -1)
    {
        if (selected)
        {
            //Debug.Log("Select Blocked!!!!!!!!!!!");
            return;
        }

        if (planetMap.ContainsKey(name))
        {
            PlanetObject sel = planetMap[name];
            if (sendMsg && connectToServer)
            {
                MsgEntry me_toSend = sel.CreateMsgEntry();
                SyncMsg  sync      = new SyncMsg();
                sync.MsgEntry.Add(me_toSend);
                Debug.Log("Send select plaent![" + name + "]");
                cm.SendMessage(sync);
            }
        }
    }
コード例 #34
0
ファイル: MsmqTraceListener.cs プロジェクト: Ampy/Work
        string FormatEntry(MsgEntry entry)
        {
            // Initialize all intrinsic properties
            entry.CollectIntrinsicProperties();

            string formattedMessage = Formatter.Format(entry);

            return formattedMessage;
        }
コード例 #35
0
ファイル: MsmqTraceListener.cs プロジェクト: Ampy/Work
 void SendMessageToQueue(MsgEntry MsgEntry)
 {
     using (IMsmqSendInterface messageQueueInterface = msmqInterfaceFactory.CreateMsmqInterface(queuePath))
     {
         using (Message queueMessage = CreateMessage(MsgEntry))
         {
             messageQueueInterface.Send(queueMessage, transactionType);
             messageQueueInterface.Close();
         }
     }
 }
コード例 #36
0
ファイル: MsgFilter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Test to see if a message meets the criteria to be processed. 
 /// </summary>
 /// <param name="log">Log entry to test.</param>
 /// <returns><b>true</b> if the message passes through the filter and should be logged, <b>false</b> otherwise.</returns>
 public abstract bool Filter(MsgEntry log);
コード例 #37
0
ファイル: PriorityFilter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Tests a log entry to see if its priority is within the allowed limits.
 /// </summary>
 /// <param name="log">Log entry to test.</param>
 /// <returns>Returns true if the log entry passes through the category filter.</returns>
 public override bool Filter(MsgEntry log)
 {
     if(log == null) throw new ArgumentNullException("log");
     return ShouldLog(log.Priority);
 }
コード例 #38
0
ファイル: EmailMessage.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Initializes a <see cref="EmailMessage"/> with the raw data to create and email, the MsgEntry, and the formatter 
 /// </summary>
 /// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param>
 /// <param name="fromAddress">Represents from whom the email is sent.</param>
 /// <param name="subjectLineStarter">Starting text for the subject line.</param>
 /// <param name="subjectLineEnder">Ending text for the subject line.</param>
 /// <param name="smtpServer">The name of the SMTP server.</param>
 /// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param>
 /// <param name="MsgEntry">The MsgEntry <see cref="MsgEntry"/> to send via email.</param>
 /// <param name="formatter">The Formatter <see cref="IMsgFormatter"/> which determines how the 
 /// email message should be formatted</param>
 /// <param name="authenticationMode">Authenticate mode to use when connecting to SMTP server.</param>
 /// <param name="userName">User name to send to SMTP server if using username/password authentication.</param>
 /// <param name="password">Password to send to SMTP server if using username/password authentication.</param>
 /// <param name="useSSL">Use SSL to connect to STMP server - if true, yes, if false, no.</param>
 public EmailMessage(string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, MsgEntry MsgEntry, IMsgFormatter formatter,
     EmailAuthenticationMode authenticationMode, string userName, string password, bool useSSL)
 {
     this.configurationData = new EmailTraceListenerData(toAddress, fromAddress, subjectLineStarter,
                                                         subjectLineEnder, smtpServer, smtpPort, string.Empty)
                                  {
                                      AuthenticationMode = authenticationMode,
                                      UserName = userName,
                                      Password = password,
                                      UseSSL = useSSL
                                  };
     this.MsgEntry = MsgEntry;
     this.formatter = formatter;
 }
コード例 #39
0
        /// <summary>
        /// Writes trace information, a message, a related activity identity and event information.
        /// </summary>
        /// <param name="eventCache">A <see cref="TraceEventCache"/> object that contains the current process ID, thread ID, and stack trace information.</param>
        /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param>
        /// <param name="id">A numeric identifier for the event.</param>
        /// <param name="message">A message to write.</param>
        /// <param name="relatedActivityId">A <see cref="Guid"/> object identifying a related activity.</param>
        /// <remarks>The <paramref name="relatedActivityId"/> is saved to a <see cref="MsgEntry"/> so the logging infrastructure can reconstruct the transfer message.</remarks>
        public override void TraceTransfer(TraceEventCache eventCache,
                                           string source,
                                           int id,
                                           string message,
                                           Guid relatedActivityId)
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties.Add(TraceEventCacheKey, eventCache);

            MsgEntry MsgEntry = new MsgEntry(string.IsNullOrEmpty(message) ? string.Empty : message,
                                             string.IsNullOrEmpty(source) ? new string[0] : new string[] { source },
                                             int.MaxValue, id, TraceEventType.Transfer, null, properties);
            //MsgEntry.RelatedActivityId = relatedActivityId;

            Messager.Write(MsgEntry);
        }
コード例 #40
0
ファイル: EmailMessage.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Initializes a <see cref="EmailMessage"/> with email configuration data, MsgEntry, and formatter 
 /// </summary>
 /// <param name="configurationData">The configuration data <see cref="EmailTraceListenerData"/> 
 /// that represents how to create the email message</param>
 /// <param name="MsgEntry">The MsgEntry <see cref="MsgEntry"/> to send via email.</param>
 /// <param name="formatter">The Formatter <see cref="IMsgFormatter"/> which determines how the 
 /// email message should be formatted</param>
 public EmailMessage(EmailTraceListenerData configurationData, MsgEntry MsgEntry, IMsgFormatter formatter)
 {
     this.configurationData = configurationData;
     this.MsgEntry = MsgEntry;
     this.formatter = formatter;
 }
コード例 #41
0
 void DrawDetail(MsgEntry m)
 {
     if(m.repr == null) {
         m.repr = UniExtensions.Serialization.JsonPrettyPrint.Format(m.msg.ToString());
     }
     GUILayout.TextArea(m.repr);
 }
コード例 #42
0
ファイル: CategoryFilter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Tests a log entry against the category filters.
 /// </summary>
 /// <param name="log">Log entry to test.</param>
 /// <returns><b>true</b> if the message passes through the filter and should be logged, <b>false</b> otherwise.</returns>
 public override bool Filter(MsgEntry log)
 {
     return ShouldLog(log.Categories);
 }
コード例 #43
0
    void DrawMsg(MsgEntry m)
    {
        GUILayout.BeginVertical ();
        GUILayout.BeginHorizontal ();
        var heading = (m.timestamp.ToString ("HH:mm:ss.ff") + " " + m.connection.url);
        heading += " " + m.msg.name;
        var color = GUI.backgroundColor;
        if(m.msg.name == "exception") {
            GUI.backgroundColor = new Color(1f, 0.85f, 0f);
        }
        m.visible = GUILayout.Toggle (m.visible, heading, rowStyle, GUILayout.ExpandWidth (true));
        GUI.backgroundColor = color;
        GUILayout.EndHorizontal ();
        if(m.visible) {
            DrawDetail(m);
        }

        GUILayout.EndVertical ();

        GUILayout.Space (5);
    }
コード例 #44
0
ファイル: TokenFunction.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Abstract method to process the token value between the start and end delimiter.
 /// </summary>
 /// <param name="tokenTemplate">Token value between the start and end delimiters.</param>
 /// <param name="log">Log entry to process.</param>
 /// <returns>Formatted value to replace the token.</returns>
 public abstract string FormatToken(string tokenTemplate, MsgEntry log);
コード例 #45
0
ファイル: MsgEnabledFilter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Tests to see if a message meets the criteria to be processed. 
 /// </summary>
 /// <param name="log">Log entry to test.</param>
 /// <returns><b>true</b> if the message passes through the filter and should be logged, <b>false</b> otherwise.</returns>
 public override bool Filter(MsgEntry log)
 {
     return enabled;
 }
コード例 #46
0
ファイル: TextFormatter.cs プロジェクト: Ampy/Work
        /// <overloads>
        /// Formats the <see cref="MsgEntry"/> object by replacing tokens with values
        /// </overloads>
        /// <summary>
        /// Formats the <see cref="MsgEntry"/> object by replacing tokens with values.
        /// </summary>
        /// <param name="log">Log entry to format.</param>
        /// <returns>Formatted string with tokens replaced with property values.</returns>
        public override string Format(MsgEntry log)
        {
            StringBuilder output = new StringBuilder();

            this.formatter.Format(log, output);

            return output.ToString();
        }
コード例 #47
0
ファイル: EmailMessage.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Initializes a <see cref="EmailMessage"/> with the raw data to create and email, the MsgEntry, and the formatter 
 /// </summary>
 /// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param>
 /// <param name="fromAddress">Represents from whom the email is sent.</param>
 /// <param name="subjectLineStarter">Starting text for the subject line.</param>
 /// <param name="subjectLineEnder">Ending text for the subject line.</param>
 /// <param name="smtpServer">The name of the SMTP server.</param>
 /// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param>
 /// <param name="MsgEntry">The MsgEntry <see cref="MsgEntry"/> to send via email.</param>
 /// <param name="formatter">The Formatter <see cref="IMsgFormatter"/> which determines how the 
 /// email message should be formatted</param>
 public EmailMessage(string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, MsgEntry MsgEntry, IMsgFormatter formatter)
 {
     this.configurationData = new EmailTraceListenerData(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, string.Empty);
     this.MsgEntry = MsgEntry;
     this.formatter = formatter;
 }
コード例 #48
0
        /// <summary>
        /// Writes trace information, a data object and event information through the Logging Application Block.
        /// </summary>
        /// <param name="eventCache">A <see cref="TraceEventCache"/> object that contains the current process ID, thread ID, and stack trace information.</param>
        /// <param name="source">An identification of the source of the trace request.</param>
        /// <param name="eventType">One of the <see cref="TraceEventType"/> values specifying the type of event that has caused the trace.</param>
        /// <param name="id">A numeric identifier for the event.</param>
        /// <param name="data">The trace data to emit.</param>
        public override void TraceData(TraceEventCache eventCache,
                                       string source,
                                       TraceEventType eventType,
                                       int id,
                                       object data)
        {
            if ((Filter == null) || Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null))
            {
                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties.Add(TraceEventCacheKey, eventCache);
                MsgEntry MsgEntry;
                if (data is XPathNavigator)
                {
                    XPathNavigator xmlData = data as XPathNavigator;
                    List<string> categories = new List<string>();
                    categories.Add(source);

                    foreach (string xpathQuery in CategoriesXPathQueries)
                    {
                        XPathNodeIterator nodeIterator = xmlData.Select(xpathQuery, NamespaceManager);
                        foreach (object value in nodeIterator)
                        {
                            categories.Add(((XPathNavigator)value).Value);
                        }
                    }

                    XmlLogEntry xmlLogEntry = new XmlLogEntry(data, categories, int.MaxValue, id, eventType, null, properties);
                    xmlLogEntry.Xml = xmlData;
                    MsgEntry = xmlLogEntry;
                }
                else if (data is MsgEntry)
                {
                    MsgEntry = data as MsgEntry;
                }
                else
                {
                    MsgEntry = new MsgEntry(data,
                                            string.IsNullOrEmpty(source) ? new string[0] : new string[] { source },
                                            int.MaxValue, id, eventType, null, properties);
                }
                Messager.Write(MsgEntry);
            }
        }
コード例 #49
0
ファイル: XmlTraceListener.cs プロジェクト: Ampy/Work
 internal virtual XPathNavigator GetXml(MsgEntry MsgEntry)
 {
     return new XPathDocument(new StringReader(new XmlMsgFormatter().Format(MsgEntry))).CreateNavigator();
 }
コード例 #50
0
ファイル: MsgFormatter.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Formats a log entry and return a string to be outputted.
 /// </summary>
 /// <param name="log">Log entry to format.</param>
 /// <returns>A string representing the log entry.</returns>
 public abstract string Format(MsgEntry log);
コード例 #51
0
ファイル: WMITraceListener.cs プロジェクト: Ampy/Work
 /// <summary>
 /// Sends an event given a predefined string
 /// </summary>
 /// <param name="message">The string to write as the event</param>
 public override void Write(string message)
 {
     MsgEntry MsgEntry = new MsgEntry();
     MsgEntry.Message = message;
     ManagementInstrumentation.Fire(MsgEntry);
 }
コード例 #52
0
ファイル: MsmqTraceListener.cs プロジェクト: Ampy/Work
        /// <summary>
        /// Create a message from a <see cref="MsgEntry"/>.
        /// </summary>
        /// <param name="MsgEntry">The <see cref="MsgEntry"/></param>
        /// <returns>A <see cref="Message"/> object.</returns>
        public Message CreateMessage(MsgEntry MsgEntry)
        {
            string formattedLogEntry = FormatEntry(MsgEntry);

            return CreateMessage(formattedLogEntry, MsgEntry.Title);
        }