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.2.9.tar.gz (5.9 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.2.9-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for httpsocketgateway-0.2.9.tar.gz
Algorithm Hash digest
SHA256 2dff741dad788ce6d5f404e0cd388df2c53b6dbce4b4a8c74f741e2caf14a5fd
MD5 245ec861321ea1b6adc7096d4167057e
BLAKE2b-256 50cd49e3e3cefbd35b0fd27be2622d08cec9fe60c045c70480bc2b3a4fbeca7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for httpsocketgateway-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bbb9188fcc4e2a448189b80b6dc539b43ee74ec025096d24cfcb97131bb7f474
MD5 aff01ed2970a02b90e3bcc83840ffcf5
BLAKE2b-256 b162003c700d1ab63866de67de62f743767a3f52e40d75f46aa212cbe197b97b

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