Exemple #1
0
		private void HandleError(String flap) {

			string e = string.Empty;
			string v = string.Empty;

			StringTokenizer stk = new StringTokenizer(flap,':');

			if(stk.HasMoreTokens) {
				e = stk.ReadToken(); 
			}
			if(stk.HasMoreTokens) {
				v = stk.ReadToken();
			}

			string message = null;
			switch(e) {
				case "901":
					message = string.Format("{0} is not currently available.", v);
					break;
				case "902":
					message = string.Format("Warning of {0} is not currently available.", v);
					break;
				case "903":
					message = string.Format("A message has been dropped, you are exceeding the server speed limit", v);
					break;
				case "980":
					throw new TocException("Incorrect nickname or password.");
				case "981":
					throw new TocException("The service is temporarily unavailable.");
				case "982":
					throw new TocException("Your warning level is currently too high to sign on.");
				case "983":
					throw new TocException("You have been connecting and disconnecting too frequently.  Wait 10 minutes and try again. If you continue to try, you will need to wait even longer.");
				case "989":
					throw new TocException("An unknown signon error has occurred " + v);
			}

			if(message != null) {
				if(Error != null) {
					Error( this, new ErrorEventArgs(int.Parse(e), message, v));
				}
			} 
			else {
				throw new TocException(flap);
			}
		}
Exemple #2
0
		private void HandleIM(String flap) {

			if(Message != null) {
				StringTokenizer stk = new StringTokenizer(flap,':');

				string from = stk.ReadToken();
				bool autoResponse = stk.ReadToken() == "T";

				if(protocol == ProtocolVersion.TOCv2){
					string unknownParam = stk.ReadToken();
				}

				string message = stk.ReadToEnd();
				
				MessageEventArgs e = new MessageEventArgs(from, message, autoResponse);
				Message(this,e);
			}
		}
Exemple #3
0
		private void HandleUpdate(String flap) {

			StringTokenizer stk = new StringTokenizer(flap,':');

			string screenName = stk.ReadToken();

			BuddyInfo buddy = Buddies[screenName];

			if(buddy != null) {

				buddy.screenName = screenName;

				buddy.online = stk.ReadToken() == "T";
				buddy.evilAmount = int.Parse(stk.ReadToken());

				long epochDate = long.Parse(stk.ReadToken());
				buddy.signOnTime = new DateTime(1970,1,1).AddSeconds(epochDate);

				int idleMinutes = int.Parse(stk.ReadToken());
				buddy.idleTime = new TimeSpan(0,idleMinutes,0);

				buddy.isOnAol = stk.ReadChar() == 'A';

				switch(stk.ReadChar()) {
					case 'A':
						buddy.userClass = BuddyUserClass.Admin;
						break;
					case 'U':
						buddy.userClass = BuddyUserClass.Unconfirmed;
						break;
					default:
						buddy.userClass = BuddyUserClass.Normal;
						break;
				}

				if(stk.HasMoreTokens) {
					buddy.isAvailable = stk.ReadChar() != 'U';
				} 
				else {
					buddy.isAvailable = true;
				}

				if(BuddyUpdate != null) {
					BuddyUpdate(this, new BuddyUpdateEventArgs(buddy));
				}
			}
			
		}
Exemple #4
0
		private void ProcessTocEvents() {
			isShuttingDown = false;
			while (!isShuttingDown) {
				string flap = ReadFlap();
				if ( flap == null ) {
					continue;
				}

				StringTokenizer stk = new StringTokenizer(flap,':');

				
				switch(stk.ReadToken().ToUpper()) {
					case "IM_IN":
						HandleIM(stk.ReadToEnd());
						break;
					case "IM_IN2":
						HandleIM(stk.ReadToEnd());
						break;
					case  "ERROR":
						HandleError(stk.ReadToEnd());
						break;
					case "CONFIG":
						HandleConfig(stk.ReadToEnd());
						break;
					case "CONFIG2":
						HandleConfig(stk.ReadToEnd());
						break;
					case "UPDATE_BUDDY":
						HandleUpdate(stk.ReadToEnd());
						break;
					case "UPDATE_BUDDY2":
						HandleUpdate(stk.ReadToEnd());
						break;
				}
			} 
		}