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.1.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.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpsocketgateway-0.3.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 32c94db92077d87f360897e679a708f98a200f46e2679b527443435138caaca3
MD5 143ccc3190e7744f313cea9a59f10234
BLAKE2b-256 af4b1920ce3b76313cf22b0b7f22ddb52e817316520d261ef5bf2eafb753bb21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for httpsocketgateway-0.3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4415fa45b8920840d234a6fd54e92ec8a36fb641ae1d87a56100c3fed4039d41
MD5 df0a59cfbb85ee598c9346ac783da152
BLAKE2b-256 93f0f287edc98df8585d212afd2121285d16d7e8045b62910e4d7df6cd03ff4d

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