Skip to content

uia4j/uia-comm

Repository files navigation

UIA Comm

Download Build Status codecov Codacy Badge License

java profiler

Socket client, server & RS232 library.

README Chinese

Android Support

  • SocketClient - tested

  • SocketServer - working

  • RS232 - NOT SUPPORT

Key Abstraction

Protocol

Provide interfaces to define data structure and handle incoming data.

  • uia.comm.protocol.Protocol - define data structure

  • uia.comm.protocol.ProtocolMonitor - handle incoming data.

Default Implementation

  • HLProtocol - Head-Length

    public HLProtocol(
        int lenStartOffset, // The offset of first byte of primary data from first byte of full data.
        int lenEndOffset,   // The offset of last byte of primary data from last byte of full data
        int lenFieldIdx,    // First byte index of LENGTH field.
        int lenFieldCount,  // Byte count of LENGTH field.
        LenReader reader,   // Reader of LENGTH field.
        byte[] head)        // Starting value of full data.
  • HOProtocol - Head Only

    public HOProtocol(
        byte[] head,        // Starting value of full data.
        int maxLength) {    // Max. length.
    }
  • HTProtocol - Head-Tail

    public HTProtocol(
        byte[] head,        // Starting value of full data.
        byte[] tail) {      // End value of full data.
    }
  • HTxProtocol - Head-Tail sepcial

    public HTxProtocol(
        byte head,          // Starting value of full data.
        int hc,             // Repeat count of head.
        byte tail) {        // End byte value of full data.
    }
  • NGProtocol - Not Good

    public NGProtocol() {
    }                       // Structrueless.
  • XMLProtocol - XML

    public XMLProtocol(     
        String rootTag) {   // XML root tag.
    }

Message Manager

Provide core functions for control flow of messages.

  • uia.comm.MessageManager

Call In/Out

Provoide interfaces to handle incoming and outgoing messages.

  • uia.comm.MessageCallIn

    • Handle Request from remote side.
    • Response from the remote side will be paired to Callout Request.
  • uia.comm.MessageCallout

    • Handle Reqeust form client side.
    • Response of the Request will be paired automatically.

Maven

<dependency>
    <groupId>org.uia.solution</groupId>
    <artifactId>uia-comm</artifactId>
    <version>0.3.3</version>
</dependency>

Dependency Libraries

Copyright and License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.