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.

Usage

Rceive http request with json -> send json and get response in json.

With client you can send json to response to an http request.

Example

Client

Send a request

# Exemple of use
if __name__ == "__main__":
    client = WebSocketClient("ws://127.0.0.1:4200/ws", simple=True)
    client.run()
    try:
        # send what you want
        # client.send({"test": "test"})
        time.sleep(60)
    except KeyboardInterrupt:
        client.close()
    except Exception as e:
        print(f"An error occurred: {e}")

Get a response

You should override the process_message method from WebSocketClient class.

class WebSocketClient(WebSocketBaseClient):
    def process_message(self, message):
        print(f"Received: {message}")

# or

client = WebSocketClient("ws://127.0.0.1", simple=True)
client.run()
# send what you want
# client.send({"test": "test"})
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.5.tar.gz (3.8 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.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpsocketgateway-0.2.5.tar.gz
  • Upload date:
  • Size: 3.8 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.5.tar.gz
Algorithm Hash digest
SHA256 3f16a75272ea9f81491141c4f6dd1830311e40f74821b4425d69a495e5a06e09
MD5 3f19dc79924620628d05fee36bc72e0c
BLAKE2b-256 7589e2fc5946bb822d74f31169f91ec30dce3be32619e1d550c8e9a1ec54fb11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for httpsocketgateway-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8dd31d853505bd5fc3b4f671981682cbe51f51f6def0563f91bf619591fe8b57
MD5 81b76bbad505e5ba192e509c2045bda8
BLAKE2b-256 6af55ba718421ece9b5ffbf92e6d5ebc7545f4f5a1d62560a68edb43649133b6

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