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

use README.md from github

Gateway

Rceive http request with json and send json with http properties to the client and wait response in json from client.

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):
        print("You receive", message)

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):
        print(f"Received: {message}")

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.8.tar.gz (4.6 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.8-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpsocketgateway-0.2.8.tar.gz
  • Upload date:
  • Size: 4.6 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.8.tar.gz
Algorithm Hash digest
SHA256 59ad7360c30c0e08f945767d76f29f98b0f5c6542c99aaec1d8ce910129c7520
MD5 a635c7de6a97f1862adc6dd676b550e6
BLAKE2b-256 417bae8a869fc1d7df5f950e6209164128fcd0f9ee82fba53a543eb92b0a7081

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for httpsocketgateway-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 13300b3f8329d844c74957231f468b98f457ca860c1efaddbafebcb039cee959
MD5 87584bb51900a6374ae5b35e28059104
BLAKE2b-256 4c64156350a248caadf4106a9e13d82f537a92ca0b94e11da08442b23e605584

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