Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can now send items for ripme to rip over tcp socket #1305

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions src/main/java/com/rarchives/ripme/App.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.rarchives.ripme;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.*;

import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -44,6 +42,33 @@ public class App {
public static String stringToAppendToFoldername = null;
private static final History HISTORY = new History();

public static class IPCThread implements Runnable {
public void run() {
String dataFromProcess;
String capitalizedSentence;
try {
ServerSocket welcomeSocket = new ServerSocket(6789);
while (true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));

DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
dataFromProcess = inFromClient.readLine();
System.out.println("Received: " + dataFromProcess);
capitalizedSentence = dataFromProcess.toUpperCase() + 'n';
outToClient.writeBytes(capitalizedSentence);
MainWindow.queueListModel.add(MainWindow.queueListModel.size(), dataFromProcess);
welcomeSocket.close();
}
} catch(IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you combine both catches into 1 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you combine both catches into 1 ?

Yea this PR is a bit rough right now, I'll fix that once i have some more free time to work on this

}
}

}

/**
* Where everything starts. Takes in, and tries to parse as many commandline arguments as possible.
* Otherwise, it launches a GUI.
Expand Down Expand Up @@ -73,6 +98,11 @@ public static void main(String[] args) throws MalformedURLException {
if (GraphicsEnvironment.isHeadless() || args.length > 0) {
handleArguments(args);
} else {
logger.info("Starting IPC thread...");
IPCThread ipcThread = new IPCThread();
Thread t = new Thread(ipcThread);
t.start();
logger.info("IPC thread started");
if (SystemUtils.IS_OS_MAC_OSX) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "RipMe");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rarchives/ripme/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
// Queue
public static JButton optionQueue;
private static JPanel queuePanel;
private static DefaultListModel queueListModel;
public static DefaultListModel queueListModel;

// Configuration
private static JButton optionConfiguration;
Expand Down