Skip to main content

Web Socket Integration

The Web socket integration method allows you to integrate the Aladdin mobile application with any other app running in local host. the Web socket integration method supports two-way communication, so both the server and the client application can send or receive messages/events.

Web Socket Integration Method in Aladdin

  1. Select the Web socket option in the Integration UI of Aladdin app.

  2. A dialog box asking for port address will appear. You must enter a valid port number. Please, use a port address between 1024 to 65535. Default port address is 8000.

    Change_Port

  3. Tap "Done" to initialize the server.

Messages / Events

Messages/ events will be communicated between the Aladdin app and the client app using JSON protocol. Below are the events and JSON structure supported in Aladdin.

  1. Scan event:

    Scan event is used to notify any barcode scan from Aladdin.

    JSON fields:

    NameTypeDescription
    event_typeStringThe event type
    scan_timeLongThe timestamp in Millies when barcode is scanned
    scan_codeStringThe barcode content
    scan_code_typeStringThe barcode type

    Example:

    {
    "Event_type": "scan",
    "Scan_time": 1705048949979,
    "Scan_code": "ABC",
    "Scan_code_type": "Code-128"
    }
  2. Scan status event:

    This event is used to notify the client app about the scanner connection status with the Aladdin app.

    JSON fields:

    NameTypeDescription
    event_typeStringThe event type
    statusBooleanThe connection status. True if HHS is connected with Aladdin app else false

    Example:

    {
    "Event_type": "connection_status",
    "Scan_time": true,
    }

Steps to test the Web socket integration with the client application

  1. Open the Web socket client application and tap Connect to server. A dialog box asking for port address will appear. Please, enter the same port address you entered in Aladdin application.

    Connect_to_Server

  2. Once connected to server, you can get barcode events in toast messages in the client app whenever a barcode is scanned by the HHS and the HHS is connected to the Aladdin app.

    Connect_to_Server

  3. Tap Get latest barcode to get the last barcode scanned by the HHS.

  4. Tap Get scanner status to get the HHS connection status with the Aladdin app. Status value will be "true" if HHS is connected to Aladdin, "false" if it is not connected.

    Status_True

  5. Tap Disconnect from server to stop the communication between the client and the Aladdin app.