Giter Site home page Giter Site logo

pubsubx's Introduction

                         ____        __   _____       __   _  __                    
                        / __ \__  __/ /_ / ___/__  __/ /_ | |/ /                    
                       / /_/ / / / / __ \\__ \/ / / / __ \|   /                     
                      / ____/ /_/ / /_/ /__/ / /_/ / /_/ /   |                      
                     /_/    \__,_/_.___/____/\__,_/_.___/_/|_|                      

Introduction

PubSubX is a framework for implementation of basic publish subscribe architecture on TCP/IP layer written in Python. It consists of two modules: Server and client. Both modules are developed using raw sockets.

Server application listens for TCP/IP requests on selected port and prints diagnostic informations (client subscribed to a topic...). It keeps track of all the clients and their subscriptions and routes their messages accordingly. It also keeps track of lost clients (that have disconnected abruptly) and messages sent to them for a certain period (default 60 seconds) Since it uses efficient Linux I/O event notification facility Epoll it can be only run on Linux OS.

Client application connects to the server and is used to interact with it and other clients (publish and receive messages). It is platform independent. It implements next set of commands

  • CONNECT <port> <name> - Connects to a server at port, with name
  • DISCONNECT - Disconnects from server
  • PUBLISH <topic> <data> - Sends (ASCII) message on a topic
  • SUBSCRIBE <topic> - Client subscribes to a topic
  • UNSUBSCRIBE <topic> - Client unsubscribes from a topic

Usage

Server module must be started with port number as argument:

PubSubX $python3 server.py 12000
INFO: Server successfully started

Client is started with no arguments after which prompt text to enter command is printed. First command that must be entered is CONNECT with appropriate server port number and client name.

PubSubX $python3 client.py
Enter command or (-h): connect 12000 homer
INFO: Connection successfully established

Information about all possible commands is given when -h is entered.

Link to the usage video is given bellow


Server module

Server module consists of 2 classes, client and server.
Client class is helper class for server's client "accounting". Server class uses efficient Linux I/O event notification facility Epoll. Since this is Linux-only facility this module cannot be used on other platforms. Epool is used to implement efficient non blocking control of multiple connections between clients and server. Simplified state machine of a single client in a server application is shown on next picture:


Client module

Client module consists of 1 class - client. Client class uses portable select mechanism for nonblocking overview of input and output sockets for external and inter-thread communication. Client has 2 loops, one for command line interface for issuing commands and other for socket monitoring and communication with server. These 2 loops communicate via sockets, command loop sends messages over to socket loop.

pubsubx's People

Contributors

gjosipovic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.