Skip to content

val-bubbleflat/laravel-echo-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1c9f013 · Oct 17, 2017

History

7 Commits
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017
Oct 17, 2017

Repository files navigation

Laravel Echo IOS

This is a project by Bubbleflat : find your perfect roommate and flatsharing

This project is wrapper to use Laravel Echo in Swift IOS project

This only work for socket.io, NOT FOR PUSHER yet !

Installation

This module can be imported with CocoaPods

pod 'LaravelEchoIOS'

Example

First, you need to import the framework :

import LaravelEchoIOS

Then you can use it like in javascript ( but you need to wait for the socket to be connected )

let token = "Auth token"
let e : Echo = Echo(options: ["host":"http://localhost:6001", "auth": ["headers": ["Authorization": "Bearer " + token]]])

e.connected(){ data, ack in

    print("CONNECTED")

    e.join(channel: "conversation.243").listen(event: ".NewMessage", callback: { data, ack in

        print(data)

    })

}

Documentation

See full Echo documentation for all available methods

All callback must been use like this :

e.connected(){ data, ack in

  // Do something when call

}

Or with a function like this

func listener(data: [Any], ack: SocketAckEmitter)

here, joining, leaving are not available yet