Skip to content
/ JSocket Public

Simple Java WebSocket Server capable of asynchronous work.

License

Notifications You must be signed in to change notification settings

RP-pl/JSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSocket

Simple Java WebSocket Server and Client capable of asynchronous work. Supports multiple clients and multiple threads.

Usage

Server

Handleable defaultHandler = (io, message) -> {
    System.out.println("Received message: " + message);
    io.writeString("Hello from server!");
};

Handleable endpointHandler = (io, message) -> {
    System.out.println("Received message: " + message);
    io.writeString("Hello from /test!");
};
        
JSocketServer server = new JSocketServer(8080,defaultHandler);
server.addEndpoint("/test", endpointHandler);
server.runSynchronously();

Client

JSocketClient client = new JSocketClient("ws://localhost:8080");
ConnectionIO io = client.getConnectionIO();
io.writeString("Hello World!");
System.out.println(io.readString(false));
io.close();

Additional protocols

This library can be easily extended with additional protocol support by implementing the Connection interface for Server and ConnectionSwitchHandler for Client.

About

Simple Java WebSocket Server capable of asynchronous work.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages