Giter Site home page Giter Site logo

pbx-server's Introduction

Introduction

Implementation of a server that simulates the behavior of a Private Branch Exchange (PBX) telephone system.

There are three modules:

  • Server initialization in main.c
  • Server module in server.c
  • The PBX module in pbx.c

Usage

pbx -h <hostname> -p <port>

  • -h <hostname> Specify the hostname to use when connecting to the server. The default is localhost.
  • -p <port #> Specify the port number to use when connecting to the server. The default is 3333.

Getting Started

  • From pre-built executable
    • demo/pbx -p 33331

Or,

  • From Source Code
    • Clone the code
    • Make using make clean at the source directory
    • Run it by typing the following command: bin/pbx -p 3333[1]

And then,

  • From another terminal window, use telnet to connect to the server as follows: telnet localhost 3333

You can now issue the following commands to the server:

pickup
dial <TU#>
chat <msg>
hangup

A simple 2 Client Client Server connection and communication looks like this (In this order):

Terminal window 1 (starting the server):

demo/pbx -p 3333

Terminal window 2 (client 1: Denoted by the number 3(First available File Descriptor)):

telnet localhost 3333

Terminal window 3(client 1: Denoted by the number 4):

telnet localhost 3333
pickup
dial 3 // connects to telnet in terminal 2 

Terminal window 2:

pickup // telnet in terminal 3 will be connected after the pickup
chat hello
.....

Terminal window 3:

chat hello to you too
......

Send hangup from either to terminate

If you make a second connection to the server from yet another terminal window, you can make calls.

[1]

You may replace 3333 by any port number 1024 or above. The server should report that it has been initialized and is listening on the specified port.port numbers below 1024 are generally reserved for use as "well-known" ports for particular services, and require "root" privilege to be used

The Base Code

Here is the structure of the base code:

.
└── pbx-server
    ├── demo
    │   └── pbx
    ├── include
    │   ├── debug.h
    │   ├── pbx.h
    │   └── server.h
    ├── lib
    │   └── pbx.a
    ├── Makefile
    ├── src
    │   ├── globals.c
    │   └── main.c
    ├── tests
    │   └── .git_keep
    └── util
        └── tester.c

The PBX Server: Overview and Details

The PBX system maintains the set of registered clients in the form of a mapping from assigned extension numbers to clients. It also maintains, for each registered client, information about the current state of the TU for that client. The following are the possible states of a TU:

  • On hook: The TU handset is on the switchhook and the TU is idle.

  • Ringing: The TU handset is on the switchhook and the TU ringer is active, indicating the presence of an incoming call.

  • Dial tone: The TU handset is off the switchhook and a dial tone is being played over the TU receiver.

  • Ring back: The TU handset is off the switchhook and a "ring back" signal is being played over the TU receiver.

  • Busy signal: The TU handset is off the switchhook and a "busy" signal is being played over the TU receiver.

  • Connected: The TU handset is off the switchhook and a connection has been established between this TU and the TU at another extension. In this state it is possible for users at the two TUs to "chat" with each other over the connection.

  • Error: The TU handset is off the switchhook and an "error" signal is being played over the TU receiver.

  • Commands from Client to Server

    • pickup
    • hangup
    • dial #, where # is the number of the extension to be dialed.
    • chat ...arbitrary text...
  • Responses from Server to Client

    • ON HOOK #, where # reports the extension number of the client.
    • RINGING
    • DIAL TONE
    • RING BACK
    • CONNECTED #, where # is the number of the extension to which the connection exists.
    • ERROR
    • CHAT ...arbitrary text...

pbx-server's People

Contributors

maxrovr avatar

Watchers

 avatar

Forkers

simhaonline

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.