GithubHelp home page GithubHelp logo

rnc505 / signalr-objc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dyknow/signalr-objc

0.0 2.0 0.0 4.96 MB

Objective-C Client for the SignalR Project works with iOS and Mac

Home Page: http://dyknow.github.com/SignalR-ObjC/

License: MIT License

signalr-objc's Introduction

SignalR-ObjC is a client library for iOS and Mac OS X. It's built on top of two popular open source libraries AFNetworking and SocketRocket. SignalR-ObjC is intended to be used along side ASP.NET SignalR, a new library for ASP.NET developers that makes it incredibly simple to add real-time functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.

For example, here's how easy it is to get started:

SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite/echo"];
connection.received = ^(NSString * data) {
    NSLog(data);
};
connection.started =  ^{
    [connection send:@"hello world"];
};
[connection start];

How To Get Started

  • Download SignalR-ObjC and try out the included Mac and iPhone example apps
    1. Install CocoaPods
      • $ [sudo] gem install cocoapods
      • $ pod setup
    2. cd SignalR-ObjC project directory
    3. $ pod install
  • Check out the documentation for a comprehensive look at the APIs available in SignalR-ObjC. NOTE: this is a work in progress and is currently outdated.
  • Questions? JabbR is the best place to find answers

Installation

  1. Install CocoaPods
    • $ [sudo] gem install cocoapods
    • $ pod setup
  2. Create or Add SignalR to your "Podfile"
Sample iOS Podfile Sample OSX Podfile
platform :ios, '5.0'
pod 'SignalR-ObjC'
platform :osx, '10.7'
pod 'SignalR-ObjC'
3. Install SignalR-ObjC into your project * $ pod install

Overview

Hubs
SRHubConnection
Core
SRConnection
Transports
SRAutoTransport SRAutoTransport chooses the best supported transport for both client and server. This achieved by falling back to less performant transports.
The default transport fallback is:
1. SRWebSocketTransport
2. SRServerSentEventsTransport
3. SRLongPollingTransport
SRWebSocketsTransport WebSockets is the only transport that establishes a true persistent, two-way connection between the client and server.
SRServerSentEventsTransport With Server Sent Events, also known as EventSource, it's possible for a server to send new data to a client at any time, by pushing messages to the client. Server Sent Events requires few new connections then Long Polling and therefore will have less latency.
SRLongPollingTransport Long polling does not create a persistent connection, but instead polls the server with a request that stays open until the server responds, at which point the connection closes, and a new connection is requested immediately. This may introduce some latency while the connection resets.

Example Usage

Persistent Connection

using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;

//Server
public class MyConnection : PersistentConnection 
{
    protected override Task OnReceived(IRequest request, string connectionId, string data) 
    {
        // Broadcast data to all clients
        return Connection.Broadcast(data);
    }
}
#import "SignalR.h"

//Client
SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite/echo"];
connection.received = ^(NSString * data) {
    NSLog(data);
};
connection.started =  ^{
    [connection send:@"hello world"];
};
[connection start];

Hubs

//Server
public class Chat : Hub 
{
    public void Send(string message)
    {
        // Call the addMessage method on all clients            
        Clients.All.addMessage(message);
    }
}
//Client
#import "SignalR.h"

// Connect to the service
SRHubConnection *hubConnection = [SRHubConnection connectionWithURL:@"http://localhost/mysite"];
// Create a proxy to the chat service
SRHubProxy *chat = [hubConnection createHubProxy:@"chat"];
[chat on:@"addMessage" perform:self selector:@selector(addMessage:)];
// Start the connection
[hubConnection start];

- (void)addMessage:(NSString *)message {
    // Print the message when it comes in
    NSLog(message);
}

Requirements

SignalR-ObjC requires either iOS 5.0 and above, or Mac OS 10.7 (64-bit with modern Cocoa runtime) and above.

ARC

  • SignalR-ObjC requires ARC

Networking

  • SignalR-ObjC uses AFNetworking. The minimum supported version of AFNetworking is 1.0.0
  • SignalR-ObjC uses SocketRocket. The minimum supported version of SocketRocket is 0.2.0

JSON

  • SignalR-ObjC uses AnyJSON. The minimum supported version of AnyJSON is 0.0.1

LICENSE

SignalR-ObjC is available under the MIT license. See the LICENSE file for more info.
SignalR-ObjC uses 3rd-party code which each have specific licenses, see ACKNOWLEDGEMENTS for contributions

signalr-objc's People

Contributors

benvium avatar brycekahle avatar cswelin avatar bounin avatar davidfowl avatar

Watchers

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