Exemplo n.º 1
0
        /// <summary>
        /// Compares 2 INF against eachother and then create a new one containing stuff that is different
        /// </summary>
        /// <param name="inf1"></param>
        /// <param name="inf2"></param>
        /// <returns></returns>
        public static INF MakeInfFromDifference(INF inf1, INF inf2)
        {
            if (inf2 == null)
                return inf1;
            System.Text.StringBuilder sb = new System.Text.StringBuilder(inf1.Type + inf1.Action);
            bool hasId = false;
            bool hasId2 = false;
            switch (inf1.Type)
            {
                case "B":       // Broadcast Message
                case "U":       // UDP Message
                    hasId = true;
                    break;
                case "E":       // Echo message
                case "D":       // Direct message
                    hasId = true;
                    hasId2 = true;
                    break;
                case "C":       // Client Message
                case "I":       // Info message
                default:        // Unknown types
                    break;
            }
            if (hasId)
                sb.Append(" " + inf1.Id);
            if (hasId2)
                sb.Append(" " + inf1.IDTwo);

            for (int x1 = 0; x1 < inf1.Param.Count; x1++)
            {
                bool found = false;
                for (int x2 = 0; x2 < inf2.Param.Count; x2++)
                {
                    if (inf1.Param[x1].Equals(inf2.Param[x2]))
                    {
                        found = true;
                        break;
                    }
                }

                // We havnt found a match. Add this one.
                if (!found)
                    sb.Append(" " + inf1.Param[x1]);

            }

            sb.Append("\n");
            // [20:37:58] BINF GQEH IDZE4ZCKFL5KEX7H7AXQW2Q7BCVLRG4AODPWJHP5Q PDAOY7W7NO2CEFQVEPQDIAP7UNNMI6L6VQSZPJY3I DE HN0 HO0 HR0 NIXmpl-633523558744590000 SL2 SF0 SS0 VEXmple\sV:20080720
            // [20:44:00] BINF GQEH IDZE4ZCKFL5KEX7H7AXQW2Q7BCVLRG4AODPWJHP5Q PDAOY7W7NO2CEFQVEPQDIAP7UNNMI6L6VQSZPJY3I DE HN1 HO0 HR0 NIXmpl-633523558744590000 SL2 SF0 SS0 VEXmple\sV:20080720
            return new INF(inf1.con, sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compares 2 INF against eachother and then create a new one containing stuff that is different
        /// </summary>
        /// <param name="inf1"></param>
        /// <param name="inf2"></param>
        /// <returns></returns>
        public static INF MakeInfFromDifference(INF inf1, INF inf2)
        {
            if (inf2 == null)
            {
                return(inf1);
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder(inf1.Type + inf1.Action);
            bool hasId  = false;
            bool hasId2 = false;

            switch (inf1.Type)
            {
            case "B":           // Broadcast Message
            case "U":           // UDP Message
                hasId = true;
                break;

            case "E":           // Echo message
            case "D":           // Direct message
                hasId  = true;
                hasId2 = true;
                break;

            case "C":           // Client Message
            case "I":           // Info message
            default:            // Unknown types
                break;
            }
            if (hasId)
            {
                sb.Append(" " + inf1.Id);
            }
            if (hasId2)
            {
                sb.Append(" " + inf1.IDTwo);
            }

            for (int x1 = 0; x1 < inf1.Param.Count; x1++)
            {
                bool found = false;
                for (int x2 = 0; x2 < inf2.Param.Count; x2++)
                {
                    if (inf1.Param[x1].Equals(inf2.Param[x2]))
                    {
                        found = true;
                        break;
                    }
                }

                // We havnt found a match. Add this one.
                if (!found)
                {
                    sb.Append(" " + inf1.Param[x1]);
                }
            }

            sb.Append("\n");
            // [20:37:58] BINF GQEH IDZE4ZCKFL5KEX7H7AXQW2Q7BCVLRG4AODPWJHP5Q PDAOY7W7NO2CEFQVEPQDIAP7UNNMI6L6VQSZPJY3I DE HN0 HO0 HR0 NIXmpl-633523558744590000 SL2 SF0 SS0 VEXmple\sV:20080720
            // [20:44:00] BINF GQEH IDZE4ZCKFL5KEX7H7AXQW2Q7BCVLRG4AODPWJHP5Q PDAOY7W7NO2CEFQVEPQDIAP7UNNMI6L6VQSZPJY3I DE HN1 HO0 HR0 NIXmpl-633523558744590000 SL2 SF0 SS0 VEXmple\sV:20080720
            return(new INF(inf1.con, sb.ToString()));
        }
Exemplo n.º 3
0
 protected virtual void UpdateInf(bool firstTime)
 {
     if (new System.DateTime(infLastUpdated).AddMinutes(5) < System.DateTime.Now)
     {
         INF tmp = new INF(hub, hub.Me);
         if (lastInf == null || (tmp.Raw != lastInf.Raw))
         {
             INF computed = INF.MakeInfFromDifference(tmp, lastInf);
             lastInf = tmp;
             hub.Send(computed);
             infLastUpdated = System.DateTime.Now.Ticks;
             updateInfTimer.Change(Timeout.Infinite, Timeout.Infinite);
         }
     }
     else if (firstTime)
     {
         updateInfTimer.Change(0, 15 * 60 * 1000 + 10);
     }
 }
Exemplo n.º 4
0
 void hub_ConnectionStatusChange(object sender, FmdcEventArgs e)
 {
     HubStatus h;
     switch (e.Action)
     {
         case TcpConnection.Disconnected:
             if (e.Data is System.Exception)
                 h = new HubStatus(HubStatus.Codes.Disconnected, (System.Exception)e.Data);
             else
                 h = new HubStatus(HubStatus.Codes.Disconnected);
             hub.RegMode = -1;
             // Sets Inf Interval to 0 when connection is disconnected
             this.infLastUpdated = 0;
             lastInf = null;
             break;
         case TcpConnection.Connected:
             h = new HubStatus(HubStatus.Codes.Connected);
             break;
         case TcpConnection.Connecting:
         default:
             h = new HubStatus(HubStatus.Codes.Connecting);
             break;
     }
     Update(con, new FmdcEventArgs(Actions.StatusChange, h));
     hub.Userlist.Clear();
 }
Exemplo n.º 5
0
 protected StrMessage ParseMessage(string raw)
 {
     raw = raw.Replace(this.Seperator, "");
     AdcBaseMessage msg = new AdcBaseMessage(con, raw);
     switch (msg.Action)
     {
         case "SUP":
             msg = new SUP(con, raw); break;
         case "SID":
             msg = new SID(con, raw); break;
         case "MSG":
             msg = new MSG(con, raw); break;
         case "INF":
             msg = new INF(con, raw); break;
         case "STA":
             msg = new STA(con, raw); break;
         case "QUI":
             msg = new QUI(con, raw); break;
         case "GPA":
             msg = new GPA(con, raw); break;
         case "CTM":
             msg = new CTM(con, raw); break;
         case "SND":
             msg = new SND(con, raw); break;
         case "GFI":
             msg = new GFI(con, raw); break;
         case "GET":
             msg = new GET(con, raw); break;
         case "RCM":
             msg = new RCM(con, raw); break;
         case "SCH":
             msg = new SCH(con, raw); break;
         case "RES":
             msg = new RES(con, raw); break;
         case "PAS":
             msg = new PAS(con, raw); break;
     }
     return msg;
 }