Skip to content
This repository has been archived by the owner on Aug 16, 2020. It is now read-only.

hden/SocketIO.JSCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocketIO.JSCore

SocketIO v1.0.x via JavaScriptCore

Why?

Socket.IO v1.0.0 is a major refactoring of the popular real-time framework. Unfortunatelly the communication protocal has changed drastically, thus most of the existing obj-c library won't work with v1.0.x.

This project is aimed for a obj-c bridge to the official framework via JavaScriptCore.

Design

------------------------------
|      socket.io obj-c       |
------------------------------
            ⬆ ⬇
------------------------------
| UIWebView + JavaScriptCore |
------------------------------
            ⬆ ⬇
------------------------------
|    socket.io JavaScript    |
------------------------------

Installation

platform :ios, '7.0'
pod 'SocketIO'

Usage

#import "SocketIO.h"

// This library is heavily inspired by the event emitter API of the official client
// Both SocketIO and Socket class are event emitter.
SocketIO *io = [[SocketIO alloc] init];

[io once:@"ready" listener:^{
    Socket *socket = [io of:@"http://localhost:8000" and:@{}];
    [socket once:@"hi" listener:^{
        // recieved response from server
    }];
    [socket emit:@"hi", nil];

    [socket emit:@"giveMeDataViaAck", @{@"test": @true}, ^(id *data) {
        // got response
    }, nil];
}];

See test suite for more code samples.

Further Readings

Development

cd Test
npm install
pod install
open ../SocketIO.xcworkspace
npm start

Licence

MIT