Show how many times we've been browsed and increment hit counter

This commit is contained in:
Zlatin Balevsky
2019-10-27 11:26:41 +00:00
parent 9ca8d1738c
commit 5eb8d75bba
5 changed files with 15 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ class MainWindowView extends BasicWindow {
private final Label connectionCount, incoming, outgoing private final Label connectionCount, incoming, outgoing
private final Label known, failing, hopeless private final Label known, failing, hopeless
private final Label sharedFiles private final Label sharedFiles
private final Label timesBrowsed
private final Label updateStatus private final Label updateStatus
public MainWindowView(String title, Core core, TextGUI textGUI, Screen screen, CliSettings props) { public MainWindowView(String title, Core core, TextGUI textGUI, Screen screen, CliSettings props) {
@@ -127,6 +128,7 @@ class MainWindowView extends BasicWindow {
failing = new Label("0") failing = new Label("0")
hopeless = new Label("0") hopeless = new Label("0")
sharedFiles = new Label("0") sharedFiles = new Label("0")
timesBrowsed = new Label("0")
updateStatus = new Label("Unknown") updateStatus = new Label("Unknown")
statusPanel.with { statusPanel.with {
@@ -142,6 +144,8 @@ class MainWindowView extends BasicWindow {
addComponent(hopeless, layoutData) addComponent(hopeless, layoutData)
addComponent(new Label("Shared Files: "), layoutData) addComponent(new Label("Shared Files: "), layoutData)
addComponent(sharedFiles, layoutData) addComponent(sharedFiles, layoutData)
addComponent(new Label("Times Browsed: "), layoutData)
addComponent(timesBrowsed, layoutData)
addComponent(new Label("Update Status: "), layoutData) addComponent(new Label("Update Status: "), layoutData)
addComponent(updateStatus, layoutData) addComponent(updateStatus, layoutData)
} }
@@ -261,6 +265,7 @@ class MainWindowView extends BasicWindow {
int failingHosts = core.hostCache.countFailingHosts() int failingHosts = core.hostCache.countFailingHosts()
int hopelessHosts = core.hostCache.countHopelessHosts() int hopelessHosts = core.hostCache.countHopelessHosts()
int shared = core.fileManager.fileToSharedFile.size() int shared = core.fileManager.fileToSharedFile.size()
int browsed = core.connectionAcceptor.browsed
incoming.setText(String.valueOf(inCon)) incoming.setText(String.valueOf(inCon))
outgoing.setText(String.valueOf(outCon)) outgoing.setText(String.valueOf(outCon))
@@ -268,5 +273,6 @@ class MainWindowView extends BasicWindow {
failing.setText(String.valueOf(failingHosts)) failing.setText(String.valueOf(failingHosts))
hopeless.setText(String.valueOf(hopelessHosts)) hopeless.setText(String.valueOf(hopelessHosts))
sharedFiles.setText(String.valueOf(shared)) sharedFiles.setText(String.valueOf(shared))
timesBrowsed.setText(String.valueOf(browsed))
} }
} }

View File

@@ -50,6 +50,8 @@ class ConnectionAcceptor {
final ExecutorService handshakerThreads final ExecutorService handshakerThreads
private volatile shutdown private volatile shutdown
private volatile int browsed
ConnectionAcceptor(EventBus eventBus, UltrapeerConnectionManager manager, ConnectionAcceptor(EventBus eventBus, UltrapeerConnectionManager manager,
MuWireSettings settings, I2PAcceptor acceptor, HostCache hostCache, MuWireSettings settings, I2PAcceptor acceptor, HostCache hostCache,
@@ -339,7 +341,8 @@ class ConnectionAcceptor {
return return
} }
browsed++
os.write("200 OK\r\n".getBytes(StandardCharsets.US_ASCII)) os.write("200 OK\r\n".getBytes(StandardCharsets.US_ASCII))
def sharedFiles = fileManager.getSharedFiles().values() def sharedFiles = fileManager.getSharedFiles().values()
@@ -349,6 +352,7 @@ class ConnectionAcceptor {
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os)) DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
JsonOutput jsonOutput = new JsonOutput() JsonOutput jsonOutput = new JsonOutput()
sharedFiles.each { sharedFiles.each {
it.hit()
def obj = ResultsSender.sharedFileToObj(it, false) def obj = ResultsSender.sharedFileToObj(it, false)
def json = jsonOutput.toJson(obj) def json = jsonOutput.toJson(obj)
dos.writeShort((short)json.length()) dos.writeShort((short)json.length())

View File

@@ -36,8 +36,8 @@ class MuWireStatusController {
model.sharedFiles = core.fileManager.fileToSharedFile.size() model.sharedFiles = core.fileManager.fileToSharedFile.size()
model.downloads = core.downloadManager.downloaders.size() model.downloads = core.downloadManager.downloaders.size()
model.browsed = core.connectionAcceptor.browsed
} }
@ControllerAction @ControllerAction

View File

@@ -20,6 +20,7 @@ class MuWireStatusModel {
@Observable int hopelessHosts @Observable int hopelessHosts
@Observable int sharedFiles @Observable int sharedFiles
@Observable int downloads @Observable int downloads
@Observable int browsed
void mvcGroupInit(Map<String,String> args) { void mvcGroupInit(Map<String,String> args) {
controller.refresh() controller.refresh()

View File

@@ -62,6 +62,8 @@ class MuWireStatusView {
label(text : bind {model.sharedFiles}, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END)) label(text : bind {model.sharedFiles}, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : "Downloading", constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100)) label(text : "Downloading", constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100))
label(text : bind {model.downloads}, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END)) label(text : bind {model.downloads}, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
label(text : "Times Browsed", constraints : gbc(gridx:0, gridy:2, anchor: GridBagConstraints.LINE_START, weightx: 100))
label(text : bind {model.browsed}, constraints : gbc(gridx: 1, gridy: 2, anchor : GridBagConstraints.LINE_END))
} }
} }
buttonsPanel = builder.panel { buttonsPanel = builder.panel {