Skip to main content

OIMWS SDK Server User Guide

OIMWS SDK Server is a server-side program written in Go, designed to handle WebSocket connections and provide instant messaging services. This document aims to guide you through the installation and operation of OIMWS SDK Server, explaining its main features and parameter configurations.

Installation

You can install OIMWS SDK Server in two ways:

  1. Installation via Go Get: Run the following command in your terminal to install OIMWS SDK Server:

    go get github.com/openim-sigs/oimws/example
  2. Clone the GitHub Repository: Clone the OIMWS GitHub Repository to your local environment:

    git clone https://github.com/openim-sigs/oimws/

    After doing so, please read the README file and execute the program in the example/ directory.

Execution

Before running OIMWS SDK Server, ensure it is correctly installed.

Running the program requires configuring some parameters, which you can set through command-line flags. Here is the main function of the program and its parameters:

func main() {
// Code omitted for clarity on parameter configuration
var sdkWsPort, logLevel *int
var openIMWsAddress, openIMApiAddress, openIMDbDir *string

// Parameter definitions and default values
openIMApiAddress = flag.String("openIM_api_address", "http://127.0.0.1:10002", "openIM api listening address")
openIMWsAddress = flag.String("openIM_ws_address", "ws://127.0.0.1:10001", "openIM ws listening address")
sdkWsPort = flag.Int("sdk_ws_port", 10003, "openIMSDK ws listening port")
logLevel = flag.Int("openIM_log_level", 5, "control log output level")
openIMDbDir = flag.String("openIMDbDir", "./db", "openIM db dir")

flag.Parse()

// Core logic code omitted
}

Parameter Explanation

  1. openIM_api_address: The listening address for the openIM API, default is http://127.0.0.1:10002.
  2. openIM_ws_address: The WebSocket listening address for openIM, default is ws://127.0.0.1:10001.
  3. sdk_ws_port: The listening port for openIMSDK WebSocket, default is 10003.
  4. openIM_log_level: The log output level, default is 5, which controls the verbosity of the logs.
  5. openIMDbDir: The directory for the openIM database, default is the ./db folder in the current directory.

Running Example

In the command line, you can modify these parameters by adding flags. For example:

./example -openIM_api_address="http://localhost:10002" -openIM_ws_address="ws://localhost:10001" -sdk_ws_port=10003 -openIM_log_level=4 -openIMDbDir="./data/db"

This will start the server and configure the service based on the provided parameters.

Conclusion

OIMWS SDK Server offers a flexible and powerful platform for handling instant messages and WebSocket connections. By following this guide, you should be able to successfully install and operate OIMWS SDK Server, as well as understand and configure its main parameters. For more advanced configurations and detailed information, refer to the project's GitHub page and related documentation.