예제 #1
0
 protected virtual void UpdateMyInfo(bool firstTime)
 {
     if (new System.DateTime(myInfoLastUpdated).AddMinutes(15) < System.DateTime.Now)
     {
         MyINFO tmp = new MyINFO(hub);
         if (lastMyInfo == null || (tmp.Raw != lastMyInfo.Raw))
         {
             lastMyInfo = tmp;
             hub.Send(lastMyInfo);
             myInfoLastUpdated = System.DateTime.Now.Ticks;
             updateMyInfoTimer.Change(Timeout.Infinite, Timeout.Infinite);
         }
     }
     else if (firstTime)
     {
         updateMyInfoTimer.Change(0, 15 * 60 * 1000 + 10);
     }
 }
예제 #2
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 MyInfo Interval to 0 when connection is disconnected
             this.myInfoLastUpdated = 0;
             lastMyInfo = null;
             break;
         case TcpConnection.Connected:
             h = new HubStatus(HubStatus.Codes.Connected);
             break;
         case TcpConnection.Connecting:
         default:
             h = new HubStatus(HubStatus.Codes.Connecting);
             break;
     }
     Update(hub, new FmdcEventArgs(Actions.StatusChange, h));
     hub.Userlist.Clear();
 }
예제 #3
0
 protected HubMessage ParseMessage(string raw)
 {
     raw = raw.Replace(this.Seperator, "");
     HubMessage msg = new HubMessage(hub, raw);
     if (!string.IsNullOrEmpty(raw))
     {
         switch (raw[0])
         {
             case '$':
                 int pos;
                 string cmd = null;
                 if ((pos = raw.IndexOf(' ')) != -1)
                     cmd = raw.Substring(0, pos).ToLower();
                 else
                 {
                     if (raw.Length >= 10)
                         break;
                     cmd = raw.ToLower();
                 }
                 if (cmd == null || cmd.Equals(string.Empty))
                     break;
                 switch (cmd)
                 {
                     case "$lock":
                         msg = new Lock(hub, raw); break;
                     case "$supports":
                         msg = new Supports(hub, raw); break;
                     case "$hubname":
                         msg = new HubNmdc.HubName(hub, raw); break;
                     case "$hello":
                         msg = new Hello(hub, raw); break;
                     case "$myinfo":
                         msg = new MyINFO(hub, raw); break;
                     case "$nicklist":
                         msg = new NickList(hub, raw); break;
                     case "$oplist":
                         msg = new OpList(hub, raw); break;
                     case "$to:":
                         msg = new To(hub, raw); break;
                     case "$quit":
                         msg = new Quit(hub, raw); break;
                     case "$getpass":
                         msg = new GetPass(hub, raw); break;
                     case "$logedin":
                         msg = new LogedIn(hub, raw); break;
                     case "$validatedenide":
                         msg = new ValidateDenide(hub, raw); break;
                     case "$forcemove":
                         msg = new ForceMove(hub, raw); break;
                     case "$connecttome":
                         msg = new ConnectToMe(hub, raw); break;
                     case "$revconnecttome":
                         msg = new RevConnectToMe(hub, raw); break;
                     case "$search":
                         msg = new Search(hub, raw); break;
                     case "$sr":
                         msg = new SR(hub, raw); break;
                 }
                 break;
             default:
                 // No command. Assume MainChat.
                 msg = new MainChat(hub, raw);
                 break;
         }
     }
     return msg;
 }