void peerLeft(Model.Peer p, ulong channelId, bool notify) { if (channelId == circleHash && notify) { chatReceived("*** " + p.username + " left at " + DateTime.Now.ToShortTimeString(), circleHash, p); } updateUserList(null, circleHash); }
void peerRenamed(string oldName, Model.Peer p) { if (p.circles.Contains(circleHash)) { chatReceived("*** " + oldName + " changed name to " + p.username + " at " + DateTime.Now.ToShortTimeString(), circleHash, p); } updateUserList(null, circleHash); }
private void userListView_MouseDoubleClick(object sender, MouseEventArgs e) { foreach (int i in userListView.SelectedIndices) { Model.Peer z = allPeersInCircle[i]; UserPanel b = new UserPanel(z); b.Dock = DockStyle.Fill; ((MainForm)App.mainForm).addOrSelectPanel(z.username, b, "(!) Files for " + z.id.ToString()); } }
public override void ReadPayload(NetDataReader message) { base.ReadPayload(message); int count = message.GetInt(); for (int i = 0; i < count; i++) { Model.Peer peer = new Model.Peer(); peer.ReadPayload(message); this.Peers.Add(peer); } }
void updateUserList(Model.Peer p) { var items = allPeersInCircle; if (items.Length == 0) { return; } string fingerprint = ""; foreach (Model.Peer p2 in items) { if (!p2.quit) { fingerprint += p2.username + p2.share.ToString() + p2.buildNumber.ToString() + p2.afk.ToString() + p2.probablyDead.ToString() + p2.maybeDead.ToString() + p2.description + p2.behindDoubleNAT + p2.quit + p2.timeQuit; } } if (lastFingerprint == fingerprint) { return; } lastFingerprint = fingerprint; if (this.InvokeRequired) { try { Invoke(new Action(delegate() { doUpdateUserList(); })); } catch (InvalidOperationException) { } } else { doUpdateUserList(); } }
public UserPanel(Model.Peer p) { InitializeComponent(); filesView.SmallImageList = iconCache; this.p = p; p.commandReceivedEvent += commandReceived; displayMessage("Attempting TCP connection to " + p.actualEndpoint.Address.ToString()); System.Threading.Thread t = new System.Threading.Thread(delegate() { p.createConnection(displayMessage); while (p.controlConnection == null) { System.Threading.Thread.Sleep(10); } displayMessage("Successfully set up connection."); p.controlConnection.send(new Model.Commands.GetFileListing("/")); }); t.Name = "Create connection thread"; t.IsBackground = true; t.Start(); updateFont(); }
public void chatReceived(string s, ulong roomId, Model.Peer p) { if (Parent != null && Parent.Parent != null && !addedEvent) { addedEvent = true; } if (roomId != this.circleHash) { return; } if (IsDisposed) { App.theCore.chatReceivedEvent -= chatReceived; return; } bool highlight = false; int count = new Regex(Regex.Escape(App.settings.getString("Username", "Username").ToLower())).Matches(s.ToLower()).Count; if (p?.id == App.theCore.id) { if (count > 1) { highlight = true; } } else { if (count > 0) { highlight = true; } } try { this.Invoke(new Action(delegate() { if (!focused && addedEvent && changeEventReceived) { TabPage p2 = (TabPage)Parent; if (!p2.Text.StartsWith("(!) ")) { p2.Text = "(!) " + p2.Text; } } historyBox.AppendText(s + Environment.NewLine); if (highlight) { historyBox.SelectionStart = historyBox.Text.Length - (s.Length + 1); historyBox.SelectionLength = s.Length; historyBox.SelectionBackColor = SystemColors.Highlight; historyBox.SelectionColor = SystemColors.HighlightText; App.doFlash(); } historyBox.SelectionStart = historyBox.Text.Length - (s.Length + 1); historyBox.SelectionLength = s.Length + 1; historyBox.SelectionFont = App.getFont(); if (p != null) { if (p.behindDoubleNAT) { historyBox.SelectionStart = historyBox.Text.Length - (s.Length + 1); historyBox.SelectionLength = s.Length + 1; historyBox.SelectionFont = new Font("Comic Sans MS", historyBox.Font.SizeInPoints); } } if (selected) { historyBox.SelectionStart = historyBox.Text.Length; historyBox.SelectionLength = 0; historyBox.ScrollToCaret(); } })); } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } }
void peerUpdated(Model.Peer p) { updateUserList(null, circleHash); }
void updateUserList(Model.Peer p, ulong channel) { updateUserList(p); }