// Methods public MessageEventArgs(Message message, Contact sender) { this.Message = message; this.Sender = sender; }
private void DataReceivedCallback(IAsyncResult ar) { int num1 = this.socketSB.EndReceive(ar); if (num1 <= 0) { this.Close(); } else { int num2; string text1 = this.messenger.TextEncoding.GetString(this.socketBuffer); string text2 = ""; while ((num2 = text1.IndexOf("\r\n")) > 0) { Match match1; string text5; text2 = text1.Substring(0, num2); text1 = text1.Substring(num2 + 2); if (!(match1 = Conversation.commandRe.Match(text2)).Success) { continue; } if ((text5 = match1.Groups["Command"].ToString()) == null) { continue; } text5 = string.IsInterned(text5); if (text5 != "USR") { if (text5 == "CAL") { goto Label_0145; } if (text5 == "JOI") { goto Label_0195; } if (text5 == "BYE") { goto Label_0235; } if (text5 == "IRO") { goto Label_02F6; } if (text5 == "MSG") { goto Label_0396; } continue; } if (match1.Groups["Message"].ToString().IndexOf("OK") < 0) { continue; } if (this.ConnectionEstablished != null) { this.ConnectionEstablished(this, new EventArgs()); } this.Invite(this.contactToCall); continue; Label_0145: if ((match1 = Conversation.CALRe.Match(match1.Groups["Message"].ToString())).Success) { this.sessionID = int.Parse(match1.Groups["sessionID"].ToString()); } continue; Label_0195: if (!(match1 = Conversation.JOIRe.Match(text2)).Success) { continue; } Contact contact1 = this.Messenger.GetContact(match1.Groups["Mail"].ToString()); contact1.SetName(match1.Groups["Name"].ToString()); if (!this.users.Contains(contact1.Mail)) { this.users.Add(contact1.Mail, contact1); } if (this.ContactJoin != null) { this.ContactJoin(this, new ContactEventArgs(contact1)); } continue; Label_0235: if (!(match1 = Conversation.BYERe.Match(text2)).Success || !this.users.ContainsKey(match1.Groups["Mail"].ToString())) { continue; } Contact contact2 = (Contact) this.users[match1.Groups["Mail"].ToString()]; this.users.Remove(contact2.Mail); if (this.ContactLeave != null) { this.ContactLeave(this, new ContactEventArgs(contact2)); } if ((this.users.Count == 0) && (this.AllContactsLeft != null)) { this.AllContactsLeft(this, new EventArgs()); } continue; Label_02F6: if (!(match1 = Conversation.IRORe.Match(text2)).Success) { continue; } Contact contact3 = this.Messenger.GetContact(match1.Groups["Mail"].ToString()); contact3.SetName(match1.Groups["Name"].ToString()); if (!this.users.Contains(contact3.Mail)) { this.users.Add(contact3.Mail, contact3); } if (this.ContactJoin != null) { this.ContactJoin(this, new ContactEventArgs(contact3)); } continue; Label_0396: if ((match1 = Conversation.messageRe.Match(text2)).Success) { string text4; int num3 = int.Parse(match1.Groups["Length"].ToString()); text2 = text1.Substring(0, num3); text1 = text1.Substring(num3); if (Conversation.TypingRe.Match(text2).Success) { if (this.UserTyping != null) { this.UserTyping(this, new ContactEventArgs(this.messenger.GetContact(match1.Groups["Mail"].ToString()))); } continue; } int num4 = text2.IndexOf("\r\n\r\n"); string text3 = text2.Substring(0, num4); if (num4 > 0) { text4 = text2.Substring(num4 + 4); } else { text4 = ""; } if (Conversation.CTRe.Match(text3).Success) { Conversation.APPRe.Match(text4); int num5 = int.Parse(Conversation.CookieRe.Match(text4).Groups["Cookie"].ToString()); continue; } Message message1 = new Message(text4, text3); message1.ParseHeader(); if (this.MessageReceived != null) { this.MessageReceived(this, new MessageEventArgs(message1, this.messenger.GetContact(match1.Groups["Mail"].ToString()))); } } } this.socketBuffer = new byte[this.socketBuffer.Length]; if (this.socketSB.Connected) { this.socketSB.BeginReceive(this.socketBuffer, 0, this.socketBuffer.Length, SocketFlags.None, new AsyncCallback(this.DataReceivedCallback), new object()); } } }