-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEcho.kt
53 lines (42 loc) · 1.37 KB
/
Echo.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package laravel.echo
import android.util.Log
import laravel.echo.channel.Channel
import laravel.echo.channel.PresenceChannel
import laravel.echo.connector.Connector
import laravel.echo.connector.SocketIoConnector
import org.json.JSONObject
/**
* Created by baslenvm on 19/8/2560.
*/
class Echo(private var options: Options) {
private var connector:Connector? = null
init {
Log.i("Echo/Status", "Start")
Log.i("Echo/Broadcaster", this.options.broadcaster)
when (this.options.broadcaster){
"socket.io" -> this.connector = SocketIoConnector(this.options)
"pusher" -> Log.e("Echo/Status", "Broadcaster is coming")
}
}
fun listen(channel: String, event: String, callback: (data: JSONObject) -> Unit):Channel {
return this.connector!!.listen(channel, event, callback)
}
fun channel(channel: String):Channel {
return this.connector!!.channel(channel)
}
fun privat(channel: String):Channel {
return this.connector!!.privateChannel(channel)
}
fun join(channel: String):PresenceChannel {
return this.connector!!.presenceChannel(channel)
}
fun leave(channel: String) {
this.connector!!.leave(channel)
}
fun socketId():String {
return this.connector!!.socketId()
}
fun disconnect(){
this.connector!!.disconnect()
}
}