A Opensource chatroom server based by Websocket and SpringBoot
First, let's prepare the environment first
- JRE 1.8+
- SQLite 3+
- 1MB+ Network
After preparing the environment, let's create the database!
- Create a file named
database.sqlite
in the same level as the downloaded Jar file - Open this database file using any SQLite tool or terminal
- Execute the creator SQL script If you are 0.0.1+, this step will automatic execute!
The Creator SQL Script
---------------------------------------------
--- Account Table
---------------------------------------------
CREATE TABLE "Accounts" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
"permission" TEXT NOT NULL DEFAULT "default",
"prefix" TEXT NOT NULL DEFAULT "Newcomer",
"uuid" TEXT NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0,
"crtime" LONG NOT NULL
);
Then use java -jar <file-name>
to start it!
Afterwards, we will create a client.js
file in this repository for the client demonstration(Completed)
Please goto release page download!
If you want connect server. You need authorization first.
Use GET
method to apply for a logged in uuid
Example
axios.get("http://localhost:8080/account/auth?username=example&password=example&auto=true")
-
username
Username of the logged-in user -
password
password -
auto
True to automatically create non-existent accounts. False to not automatically create non-existent accounts
After authorization, let's create a websocket connection!
Use new Websocket("<url>")
to create a new websocket connection
Example
const client = new websocket("ws://localhost:8080/chanket/" + uuid)
If you use your uuid to connect to the server without logging in, the websocket connection will be automatically disconnected
After successfully creating the link, let's send the message!
client.send('message ${GLOBAL} "Build completed! I am happy! It\'s work!"')
arguments[0]
command, heremessage
send message commandargumemts[1]
receive object,${GLOBAL}
refers to all people online, use|
to split (use uuid)arguments[2]
message, use double quotes if there are spaces so that it is not split as other arguments
chanket.source.language
Set the language environment of the current server
Available language environments.
en-US
English environment ---- Official translationcn-ZH
Chinese environment ---- Official translation