B4i Library Socket.IO Client Library


Active Member
Licensed User
Here is the Socket.IO Client library wrap for this Github Project.
Click here for the B4A wrapper

Version: 1.01
  • iSocketIOClient
    • Events:
      • OnConnect: will be raised on successful connection
      • OnConnecting: will be raised whenever it tries to connect to the server
      • OnDisconnect (reason As String): will be raised on disconnection, you need to reconnect manually
      • OnError (reason As String): will be raised if any error occurs
      • OnReconnectAttempt (attemptNumber As Int): will be raised if it tries to reconnect
      • OnReconnecting (reason As String): will be raised if it tries to reconnect
    • Functions:
      • AddEvent (server_event As String, app_event As String)
        Add event listener
      • Connect (host As String, secure As Boolean)
        Connect SocketIO to the server
        Other parameters will have default value as followings:
        reconnection = True
        reconnectionAttempts = Infinite
        reconnectionDelay = 1
        reconnectionDelayMax = 10
        timeout = 30
      • ConnectWithOptions (host As String, secure As Boolean, reconnection As Boolean, reconnectionAttempts As Int, reconnectionDelay As Int, reconnectionDelayMax As Int, timeout As Int)
        Connect SocketIO to the server with custom options
      • Disconnect
        Disconnect SocketIO
        On successful disconnection, it will raise 'OnDisconnect' event
      • Emit (event As String, str As String)
        Sends a message to the server, requesting an ack.
        NOTE: It Is up to the server send an ack back, just calling this method does not mean the server will ack.
        Check that your server’s api will ack the event being sent.
      • Initialize (event As String, callback As Object)
        Initializes the Socket.io object
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • RemoveEvent (server_event As String, app_event As String)
        Remove event listener
      • SendAck (ack As Object, data As Object)
        Call to acknowledge receiving an event.
      • setConnectParams (params As Map)
        GET parameters that will be included in the connect url.
  1. Its recommended to download the framework file directly from the safari of your mac.
  2. Copy XML file to B4I additional library folder.
  3. Copy .framework, .h and .a files to Libs folder of the local build server
Example Attached.
For the server code you can check Socket.IO Github example or you can use this following chat server example (written in javascript) [attached]:

var express = require('express');
var app = express();

// const fs = require('fs');

// var options = {
//   key: fs.readFileSync('./key.pem'),
//   cert: fs.readFileSync('./cert.pem'),
//   passphrase: "password of cert/key file"
// };

// var server = require('https').createServer(options, app);

var server = require('http').Server(app);

var io = require('socket.io')(server);
var users = {};

server.listen(999, function(){
  console.log('listening on *:999');

io.sockets.on('connection', function(socket){
    console.log("User Connected");

    socket.on('user_msg', function(data,callback){
        io.emit('new_message', data);
        callback("Data Received");

    socket.on('disconnect', function(data){
        console.log('User disconnected');
To run this example server code:
  1. Download NodeJS.
  2. Install it.
  3. Download library zip file and extract.
  4. Run cmd inside server folder
  5. Run npm install
  6. It will take some time to complete.
  7. After that run node app.js
  8. It will show listening on *:999
  9. Now create you app and connect.
  10. That's it!
Update v1.01:
  1. Added ConnectParams method for sending additional GET parameters.

Download framework files from here


Last edited: