Code Monkey home page Code Monkey logo

igap-android's Introduction

##iGap Client Connection for Android This repo contains the official source code of iGapSocket Connection On Android system.

##Language These codes are written in Java language and are used for Android systems.

###The way of connection to server Because of the possibility of receiving different responses from the server with/without request, in this report, it is used protobuffer for connecting to server.

RequestQueue class is used for sending request to the server. All requests are sent using [sendRequest] method. sendRequest method is a variadic function that accepts at least unlimited number of input as RequestWraper. Sending request
1- Create a builder of Intended protobuffer
2- Fill the methods with setters that require decimalisation for sending.
3- Create a new RequestWrapper and then set the number that is corresponded with this proto in the LookupTable as actionId. For example, ConnectionSymmetricKey is corresponded with actionId2. So send it using sendRequest method after filling RequestWrapper by proto and Id.
####Example for sending Request

  ProtoConnectionSecuring.ConnectionSymmetricKey.Builder connectionSymmetricKey = ProtoConnectionSecuring.ConnectionSymmetricKey.newBuilder();
  connectionSymmetricKey.setSymmetricKey(ByteString.copyFrom(encryption));
  RequestWrapper requestWrapper = new RequestWrapper(2, connectionSymmetricKey);
  try {
      RequestQueue.sendRequest(requestWrapper);
  } catch (IllegalAccessException e) {
      e.printStackTrace();
  }

After receiving response from the server, use HandlerResponse for reading the message. At this class, we know automatically that it is necessary to decrypt the codes before reading the messages. Then we send byteArray to the HelperUnpackMessage.
After fetching the actionId in this class, we find intended name by it at the Lookup Table.

Notice: during naming the classes that are exist as Response in LookupTable, it is necessary that the class name be the same with the name in the LookupTable.

We create dynamically a sample of response class by instanceResponseClass method for recievinf response. Then using received ByteArray from the server that is now divided to ActionId and ProtoObject, invite the existing constructor and amount it. As a result of this, after receiving any response, the message is sending to HelperUnpackMessage automatically and there, amounting and inviting given received class. So we can see all receiving responses from the server in Response classes.

example for get response

  ProtoConnectionSecuring.ConnectionSymmetricKeyResponse.Builder builder = (ProtoConnectionSecuring.ConnectionSymmetricKeyResponse.Builder) message;
  ProtoConnectionSecuring.ConnectionSymmetricKeyResponse.Status status = builder.getStatus();
  int statusNumber = status.getNumber();

  if (statusNumber == Config.REJECT) {

      WebSocketClient.getInstance().disconnect();

  } else if (statusNumber == Config.ACCEPT) {
      G.isSecure = true;

      G.ivSize = builder.getSymmetricIvSize();
      String sm = builder.getSymmetricMethod();
      G.symmetricMethod = sm.split("-")[2];
  }

The main variables used in the program:

The Global variables are set in G class. Sent messages are encrypted by symmetricKey.
ivSize is used for iv and sent message Separation.
isSecure stands for security detection.
lookupMap ActionId stands for maintaining list and response classes name.

in this page,there are general setting for example the amount of delay for TimeOut as well as server adress and other settings.

igap-android's People

Contributors

rooyekhat avatar saeedmozaffarigithub avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.