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

Documentation on making a server #100

Open
bowbahdoe opened this issue Nov 14, 2024 · 2 comments
Open

Documentation on making a server #100

bowbahdoe opened this issue Nov 14, 2024 · 2 comments

Comments

@bowbahdoe
Copy link

Just calling attention to there not really being thorough documentation on how to make a server that isn't SCP or SFTP.

I realized this because I wanted to try and make one of those basic "chat app" demos and got lost.

For one, just having server.start(); does not seem to work and the JVM will just exit. I needed to put a spurrious while (true) {} to keep everything alive.

The server has createContext, which I think is where I need to look to (mapping to the createContext on the sun http server, this feels like the place to attach a handler) but I feel like I lack context on how to construct and utilize the arguments - SshEngineContext daemonContext, SocketChannel sc

@ludup
Copy link
Contributor

ludup commented Nov 15, 2024

I had a draft document for creating an interactive terminal which I have now put live. Whilst this is not a tutorial to create a chat application, it shows the best way to implement a terminal commands, which could quite easily be adapted to a chat type application.

https://jadaptive.com/java-ssh-library/maverick-synergy/creating-an-interactive-terminal/

I would suggest you start with writing a chat command that can read from the chat database and display messages, and that can send messages from what the user types. To start it, just log in to the terminal and type chat to start.

If you manage to do that and then want the user to enter that command immediately without typing it, there is probably a way to do so, just ask. :|

The server is asynchronous by nature, having start block is not ideal for many solutions so you have to handle this yourself if your putting in in a basic application. However, this is catered for in the shutdown future object. Just use this to wait for the server to shutdown (this assumes some other thread will shut it down or the process terminates).

server.start();
server.getShutdownFuture().waitForever();

@bowbahdoe
Copy link
Author

Going through that process now. I'm seeing a processStdinData(byte[]) in the docs but I can't find it in the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants