private void OnJoinAfterInvite(MessageRouter router, Message message, object tag) { router.AddCodeEvent("JOI", new ResponseReceivedHandler(OnJoinReceived), null); OnJoinReceived(router, message, null); ((OperationCompleteEvent)tag).Execute(new OperationCompleteArgs()); }
private void RegisterCodeEvents() { sbRouter.AddCodeEvent("MSG", new ResponseReceivedHandler(OnMsgReceived), null); sbRouter.AddCodeEvent("BYE", new ResponseReceivedHandler(OnByeReceived), null); sbRouter.AddCodeEvent("JOI", new ResponseReceivedHandler(OnJoinReceived), null); }
private void OnLST(MessageRouter router, Message message, object tag) { Pair pair = (Pair)tag; OperationCompleteEvent op = (OperationCompleteEvent)pair.First; int numUsersLeft = (int)pair.Second; Regex.Regex regex = new Regex.Regex( @"(?<username>\S+)\s+(?<screenName>\S+)\s+(?<listID>\d+)\s*(?<groupList>.*)"); Regex.Match match = regex.Match(message.Arguments); if (match.Success) { string username = match.Groups["username"].Value; string screenName = this.UriUnquote(match.Groups["screenName"].Value); int listID = int.Parse(match.Groups["listID"].Value); Friend friend = new Friend(username, OnlineStatus.Offline, 0); friend.DisplayName = screenName; friend.EmailAddress = username; if ((listID & 1) == 1) // forward list { if (!this.settings.ForwardList.Contains(friend)) { this.settings.ForwardList.Add(friend); } } if ((listID & 2) == 2) // allow list { if (!this.settings.AllowList.Contains(friend)) { this.settings.AllowList.Add(friend); } } if ((listID & 4) == 4) // block list { if (!this.settings.BlockList.Contains(friend)) { this.settings.BlockList.Add(friend); } } if ((listID & 8) == 8) // reverse list { if (!this.settings.ReverseList.Contains(friend)) { this.settings.ReverseList.Add(friend); } // if this person isn't on the allow or blocking list, then they have added // me to their forward list. Inform the user if (!this.settings.AllowList.Contains(friend) && !this.settings.BlockList.Contains(friend)) { this.HandleNewFriend(friend); } } } // check if we have finished yet if (--numUsersLeft == 0) { foreach (Friend friend2 in this.settings.ForwardList) { friend2.Blocked = this.settings.BlockList.Contains(friend2); if (!this.control.ContainsFriend(friend2.Username)) { this.control.AddFriend(friend2); } } op.Execute(new ConnectionCompleteArgs()); } else // replace number of users left { router.AddCodeEvent("LST", new ResponseReceivedHandler(OnLST), new Pair(op, numUsersLeft)); } }