Artwork

Content provided by 5by5 Broadcasting. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by 5by5 Broadcasting or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

103: Don’t Hate Us, Nolan

54:05
 
Share
 

Manage episode 123541117 series 27172
Content provided by 5by5 Broadcasting. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by 5by5 Broadcasting or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Discussion

Pushing info to clients

  • Long Polling
    • Client sends request to server, waits for response or timeouts (Loop)
    • Can send and receive information, but not full-duplex
    • iOS Implementation
      • NSURLConnection sendSynchronousRequest
    • Common uses
      • Fallback from Websockets and SSE when streams are unreliable or impractical
  • HTTP Streams
    • Can only push information to your client
    • If you need to send info back to server use standard rest approach
    • Transported over simple HTTP
    • Built in support for re-connection and event-id
    • iOS Implementation
      • Server Sent Events (SSE)
      • NSURLSession, NSInputStream, NSSteamEvent
      • Setup the connection
      • Implement code to handleEvents from the input stream
    • Common uses
      • Stock ticker streaming
      • “Status” feed updating
      • Push Notifications
  • Websockets
    • Designed to overcome many of the pitfalls/shortcomings described in RFC 6202
    • Standardized by IETF (Internet Engineering Task Force) in 2011
    • Can send and receive information (full-duplex pipe)
    • Protocol based on TCP
    • Uses HTTP only for initial handshake, while leveraging existing HTTP infrastructure
    • iOS Implementation
      • CFStreamCreatePairWithSocketToHost takes url, read and write stream
      • Cast read and write stream to NSInputStream and NSOutputStream, respectively
      • Set delegate for input and output streams
      • Schedule both in a run loop (Can do without but will block the execution of other code)
      • Open connection
      • Write code to handleEvents from the input stream
      • Implement message sending via the output stream
    • Server considerations
      • Not as easy to get started with as a generic web server
      • Buy one, borrow one or build one
    • Common uses
      • Chat
      • Player vs. Player games
      • Real time interactions
  • Popular Abstractions/Frameworks

At-a-glance Comparison

Websockets SSE Long Polling
Client Performance Best Best Worst
Server Performance Best Worst Worst
Complexity Highest Lowest Mid
When to Use 2-way messaging Push to Client Just getting started

Picks

Darryl

John

Alternative show title suggestions

  • Uncanny valley
  • The cooker's always on
  • Canonical Framing Technique

Thanks to Braintree for sponsoring this episode of iOhYes. If you're building a mobile app and searching for a simple payments solution, check out Braintree. For your first $50,000 in transactions fee-free, go to braintreepayments.com/yes.

  continue reading

100 episodes

Artwork

103: Don’t Hate Us, Nolan

iOhYes

published

iconShare
 
Manage episode 123541117 series 27172
Content provided by 5by5 Broadcasting. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by 5by5 Broadcasting or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Discussion

Pushing info to clients

  • Long Polling
    • Client sends request to server, waits for response or timeouts (Loop)
    • Can send and receive information, but not full-duplex
    • iOS Implementation
      • NSURLConnection sendSynchronousRequest
    • Common uses
      • Fallback from Websockets and SSE when streams are unreliable or impractical
  • HTTP Streams
    • Can only push information to your client
    • If you need to send info back to server use standard rest approach
    • Transported over simple HTTP
    • Built in support for re-connection and event-id
    • iOS Implementation
      • Server Sent Events (SSE)
      • NSURLSession, NSInputStream, NSSteamEvent
      • Setup the connection
      • Implement code to handleEvents from the input stream
    • Common uses
      • Stock ticker streaming
      • “Status” feed updating
      • Push Notifications
  • Websockets
    • Designed to overcome many of the pitfalls/shortcomings described in RFC 6202
    • Standardized by IETF (Internet Engineering Task Force) in 2011
    • Can send and receive information (full-duplex pipe)
    • Protocol based on TCP
    • Uses HTTP only for initial handshake, while leveraging existing HTTP infrastructure
    • iOS Implementation
      • CFStreamCreatePairWithSocketToHost takes url, read and write stream
      • Cast read and write stream to NSInputStream and NSOutputStream, respectively
      • Set delegate for input and output streams
      • Schedule both in a run loop (Can do without but will block the execution of other code)
      • Open connection
      • Write code to handleEvents from the input stream
      • Implement message sending via the output stream
    • Server considerations
      • Not as easy to get started with as a generic web server
      • Buy one, borrow one or build one
    • Common uses
      • Chat
      • Player vs. Player games
      • Real time interactions
  • Popular Abstractions/Frameworks

At-a-glance Comparison

Websockets SSE Long Polling
Client Performance Best Best Worst
Server Performance Best Worst Worst
Complexity Highest Lowest Mid
When to Use 2-way messaging Push to Client Just getting started

Picks

Darryl

John

Alternative show title suggestions

  • Uncanny valley
  • The cooker's always on
  • Canonical Framing Technique

Thanks to Braintree for sponsoring this episode of iOhYes. If you're building a mobile app and searching for a simple payments solution, check out Braintree. For your first $50,000 in transactions fee-free, go to braintreepayments.com/yes.

  continue reading

100 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide