Skip to main content

A small socket gateway server. A simple socket client for sending json

Project description

Gateway Server or Client

This is client and server code for a gateway between internal and external network. That's to provide a way to communicate between the inside and the outside of network environment.

NOT FOR PRODUCTION USE

Usage

use README.md from github

Gateway

Receive http request (with json and files) and send json with http properties to the WSClient (socket) and wait response in json from client to send it back to the http request (only json).

WSClient

modify process_message method to handle, process and respond to the message received from the gateway.

You can also send json without modification to communicate with any other server (ws server) with the simple parameter.

Example

Client

Send a request

# Exemple of use
from httpSocketGateway import WSClient
import time

class CustomWSClient(WSClient):

    # Override the process_message method
    def process_message(self, message, files_path):
        print("You receive", message)
        return {"success": "Hello World"}, []

client = CustomWSClient('localhost', 8080, reconnect=True, simple=True)
client.run()
time.sleep(1)
client.send({
        "Hello": "World"
})
time.sleep(30)
client.stop()

Receive a request

You should override the process_message method from WSClient class.

from httpSocketGateway import WSClient
import time

class WebSocketClient(WebSocketBaseClient):
    def process_message(self, message, files_path):
        print(f"Received: {message}")
        return {"success": "Hello World"}, []

client = WebSocketClient("localhost", 8080, simple=True)
client.run()
time.sleep(1)
client.close()

simple parameter is used to send json without modification to match with the gateway server.

With simple parameter you can send json to any other server.

Gateway

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpsocketgateway-0.3.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpsocketgateway-0.3.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file httpsocketgateway-0.3.0.tar.gz.

File metadata

  • Download URL: httpsocketgateway-0.3.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for httpsocketgateway-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0d1f9b4393a1eaac54dd319e0b8d00a1452cb14a9d71a00e01231b298e549d3a
MD5 253e431862b76648128c104c12923e85
BLAKE2b-256 1359b09ba885f09267a63b5b0d28c660eb42838cac960f18524528d96ec67ecc

See more details on using hashes here.

File details

Details for the file httpsocketgateway-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for httpsocketgateway-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7919710e1952ebd69a767f12352d3aa99f2e3a431fb976e0b0ac5066c9ee745
MD5 f4f7c412887665ac20ab688e5e65bf9e
BLAKE2b-256 1fb6b654fe0c94d3b16e22f065e325673523109ab83fded5340b49e143234d65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page