Skip to content

vinhphuctadang/XTerm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview:

A simple ChatServer (yet a panel) for sending and recieving JSON messages between clients For full access, python 3.x is required

How to use ?

In order to take advantage of the server,

First, start XTerm.exe (or start an x86 for 32 bit machine). Next, from any programming language (requires socket library supported):

socket = new Socket ('localhost', 16472) // default XTerm port is 16472
// from now on we can send and recieve via the socket 
// but watch out
// A message is consisting of 2 parts: first 4 bytes are for message size (in byte, denote n) and next n bytes represent the message content in json format

socket.close ()

we can accomplish these tasks:

  1. Query some information of kernel: You should sent a Message (format shown below) comprising of:
    {
      "type" : "request"
      "function" : "kernel",
      "request" : "get"
      "variable" : "<any_variable>"
    }
    
Response will have a form like:
    {
      "type": "response"
      "success" : "true" // or "success":"false"
      "result": "<result_content>"
    }
  1. Create a channel, from now on the connection (socket) is used for publishing, see MQTT for more information:
    {
      "type" : "request"
      "function" : "kernel",
      "request" : "create"
      "channel" : "<channel_name>" 
    }
After the sending attempt, socket should recieve a message contain 
    {
     "type":"response"
     "result":"<register_channel_name>", 
     "success":"true"
     }
   
 otherwise a message 
    {
    "type":"response"
    "success": "false"
    "result":"<error_description>"
    } 
 is returned
  1. Subscribe a channel:
    {
      "type":"response"
      "type" : "request"
      "function" : "kernel",
      "request" : "subscribe"
      "channel" : "<channel_name>" 
    }
    
if succeed, the kernel-XTerm- should return a json message: 
    {
      "type":"response"
      "success":"true",
      "channel":"<subscribed_channel_name>"
    }
else a message which formed
    {
      "type":"response"
      "success":"false",
      "result":"error_description"
    }
    is returned
From the time of successful subscription, the socket will be recieving messages having structure like this:
    {
      "type":"noftify",
      "channel":"subscribed channel"
      
      ...      
    }
  1. Accepted function via socket: <to_be_continue>

About

ChatServer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages