Introduction
Quick Start
Introduction
This SDK provides a simple and efficient way to communicate with GMSSH services, based on the JSON-RPC 2.0 protocol, achieving high-performance data exchange through Unix Socket files.
Core Features
- High-performance communication based on Unix Socket
- Follows JSON-RPC 2.0 standard protocol
- Supports Python 3.10+ async programming
- Simple and easy-to-use API design
Platform Compatibility
This SDK is based on Unix Socket communication, only supports Linux and macOS, Windows is not supported.
Environment Preparation
Python Environment Requirements
Version Requirements
Current SDK only supports Python 3.10 and above
Install Python 3.10+
Visit Python Official Website to download and install the Python version for your operating system.
Verify Installation
python3 --version
# Example output: Python 3.10.0Install SDK
Use pip to install the latest version of the SDK:
pip3 install simplejrpcVerify installation:
python3 -c "import simplejrpc; print('SDK installed successfully!')"Quick Start
Create Minimal Application
Create a file named main.py:
# main.py
import asyncio
from simplejrpc.app import ServerApplication
from simplejrpc.response import jsonify
# Create application instance, specify socket file path
app = ServerApplication("app.socket")
@app.route(name="echo")
async def echo(message: str, lang: str):
"""Echo interface with validation"""
return jsonify(data=f"Received message: {message}", msg="Message processed")
@app.route(name="hello")
async def hello():
"""Simple greeting endpoint"""
return jsonify(data="Hello, GMSSH!", msg="Request successful")
if __name__ == "__main__":
asyncio.run(app.run())Tips
Note that the value of name in @app.route(name="hello") must match the decorated method name, i.e., hello.
When returning a response, jsonify will default to a 200 code status. If you want to specify a different code, just add the code field in the return.
Start Service
python3 main.pySuccess Message
After the service starts, an app.socket file will be generated in the current directory for communication with the GMSSH main program.
