0.0.1-b • Published 11 months ago

simplechatcommand_server v0.0.1-b

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

SimpleChatCommand_Sever--簡易聊天指令伺服器

Quality Gate Status Bugs Security Rating example workflow

這是基於websocket的簡易聊天服務,可供建立一般聊天室或是作為WebRTC的信令伺服器使用

Api Docs

參閱文檔

如何使用

以下記述了一些常見的使用範例

  • 建立伺服器
import * as UV from "./Src/UserValidator.js";
import * as SCC from "./Src/SimpleChatCommand_Server.js";
import * as my_ws from "./Src/MessageManagerWebSocket.js";

let messageManager=new my_ws.MessageManagerWebSocket(8080);
let userValidator=new UV.UserValidator_SQLite("testX.db");
let sccObj=new SCC.SimpleChatCommand_Server(userValidator,messageManager);
messageManager.Start();
  • 加入新使用者
userValidator.CreateUser(<username>,<password>);
  • 關閉伺服器
messageManager.Stop();
  • 加入客製指令
sccObj.AddCustomerCommand("Customer1",async(sender,data)=>{
    ...
})

指令種類

目前提供以下五種指令,可以透過AddCustomerCommand方法自行擴充, 超連結為對應Command_Structure,沒有超連結的表示不帶有資料欄請帶入null

指令格式

目前與伺服器溝通的管道是通過webSocket傳送Json,其定義對應到以下類別

  • CommandStruct 為最基礎的結構,以下的結構都會包在其中的Data中,範例如下:
{
    "Command":<Command_Name>,
    "Data":<Command_Structure>
}
0.0.1-b

11 months ago

0.0.1-a

11 months ago

0.0.1

11 months ago