├── .editorconfig
├── .gitattributes
├── .github
└── workflows
│ └── test.yml
├── .gitignore
├── LICENSE-APACHE
├── LICENSE-MIT
├── MAKE.md
├── Makefile
├── README.md
├── build.gradle.kts
├── docs
├── alltypes
│ └── index.html
├── ch.kuon.phoenix
│ ├── -channel
│ │ ├── -event
│ │ │ ├── -c-l-o-s-e.html
│ │ │ ├── -e-r-r-o-r.html
│ │ │ ├── -j-o-i-n.html
│ │ │ ├── -l-e-a-v-e.html
│ │ │ ├── -r-e-p-l-y.html
│ │ │ ├── event.html
│ │ │ └── index.html
│ │ ├── -life-cycle-events.html
│ │ ├── -message
│ │ │ ├── -init-.html
│ │ │ ├── get-error.html
│ │ │ ├── index.html
│ │ │ ├── is-error.html
│ │ │ ├── response.html
│ │ │ └── status.html
│ │ ├── -push
│ │ │ ├── -init-.html
│ │ │ ├── index.html
│ │ │ └── receive.html
│ │ ├── -state
│ │ │ ├── -c-l-o-s-e-d.html
│ │ │ ├── -e-r-r-o-r-e-d.html
│ │ │ ├── -j-o-i-n-e-d.html
│ │ │ ├── -j-o-i-n-i-n-g.html
│ │ │ ├── -l-e-a-v-i-n-g.html
│ │ │ ├── index.html
│ │ │ └── state.html
│ │ ├── index.html
│ │ ├── join.html
│ │ ├── leave.html
│ │ ├── off.html
│ │ ├── on-close.html
│ │ ├── on-error.html
│ │ ├── on.html
│ │ ├── params.html
│ │ ├── push.html
│ │ ├── socket.html
│ │ ├── to-string.html
│ │ └── topic.html
│ ├── -ex-timer
│ │ ├── -init-.html
│ │ ├── callback.html
│ │ ├── index.html
│ │ ├── reset.html
│ │ ├── schedule-timeout.html
│ │ ├── timer-calc.html
│ │ ├── timer.html
│ │ └── tries.html
│ ├── -library-test
│ │ ├── -init-.html
│ │ ├── index.html
│ │ ├── test-broadcast.html
│ │ ├── test-connect.html
│ │ ├── test-echo.html
│ │ ├── test-join-error.html
│ │ ├── test-presence.html
│ │ ├── test-timer.html
│ │ └── test-u-r-l.html
│ ├── -presence
│ │ ├── -entry
│ │ │ ├── -init-.html
│ │ │ ├── get-metas.html
│ │ │ ├── index.html
│ │ │ └── raw-data.html
│ │ ├── -init-.html
│ │ ├── -options
│ │ │ ├── -event-names
│ │ │ │ ├── -init-.html
│ │ │ │ ├── diff.html
│ │ │ │ ├── index.html
│ │ │ │ └── state.html
│ │ │ ├── -init-.html
│ │ │ ├── event-names.html
│ │ │ └── index.html
│ │ ├── channel.html
│ │ ├── in-pending-sync-state.html
│ │ ├── index.html
│ │ ├── list.html
│ │ ├── on-join.html
│ │ ├── on-leave.html
│ │ ├── on-sync.html
│ │ └── opts.html
│ ├── -socket
│ │ ├── -init-.html
│ │ ├── -message
│ │ │ ├── -init-.html
│ │ │ ├── event.html
│ │ │ ├── index.html
│ │ │ ├── join-ref.html
│ │ │ ├── payload.html
│ │ │ ├── ref.html
│ │ │ ├── to-string.html
│ │ │ └── topic.html
│ │ ├── -options
│ │ │ ├── -init-.html
│ │ │ ├── heartbeat-interval-ms.html
│ │ │ ├── index.html
│ │ │ ├── logger.html
│ │ │ ├── params.html
│ │ │ ├── reconnect-after-ms.html
│ │ │ ├── rejoin-after-ms.html
│ │ │ └── timeout.html
│ │ ├── -state
│ │ │ ├── -c-l-o-s-e-d.html
│ │ │ ├── -c-l-o-s-i-n-g.html
│ │ │ ├── -c-o-n-n-e-c-t-i-n-g.html
│ │ │ ├── -c-r-e-a-t-e-d.html
│ │ │ ├── -o-p-e-n.html
│ │ │ ├── -u-n-k-n-o-w-n.html
│ │ │ ├── index.html
│ │ │ └── state.html
│ │ ├── channel.html
│ │ ├── connect.html
│ │ ├── connection-state.html
│ │ ├── disconnect.html
│ │ ├── end-point-u-r-l.html
│ │ ├── index.html
│ │ ├── is-connected.html
│ │ ├── log.html
│ │ ├── off.html
│ │ ├── on-close.html
│ │ ├── on-error.html
│ │ ├── on-message.html
│ │ ├── on-open.html
│ │ ├── opts.html
│ │ ├── push.html
│ │ ├── to-string.html
│ │ └── url.html
│ ├── index.html
│ └── url.html
├── index-outline.html
├── index.html
├── package-list
└── style.css
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
├── main
└── kotlin
│ └── ch
│ └── kuon
│ └── phoenix
│ ├── Channel.kt
│ ├── ExTimer.kt
│ ├── Presence.kt
│ └── Socket.kt
└── test
├── kotlin
└── ch
│ └── kuon
│ └── phoenix
│ └── LibraryTest.kt
├── mock_server
├── .formatter.exs
├── .gitignore
├── README.md
├── config
│ ├── config.exs
│ ├── dev.exs
│ ├── prod.exs
│ ├── prod.secret.exs
│ └── test.exs
├── lib
│ ├── mock_server.ex
│ ├── mock_server
│ │ ├── application.ex
│ │ └── counter.ex
│ ├── mock_server_web.ex
│ └── mock_server_web
│ │ ├── channels
│ │ ├── mock_channel.ex
│ │ ├── mock_presence.ex
│ │ └── user_socket.ex
│ │ ├── endpoint.ex
│ │ ├── gettext.ex
│ │ ├── router.ex
│ │ └── views
│ │ ├── error_helpers.ex
│ │ └── error_view.ex
├── mix.exs
├── mix.lock
├── priv
│ └── gettext
│ │ ├── en
│ │ └── LC_MESSAGES
│ │ │ └── errors.po
│ │ └── errors.pot
└── test
│ ├── mock_server_web
│ ├── channels
│ │ └── mock_channel_test.exs
│ └── views
│ │ └── error_view_test.exs
│ ├── support
│ ├── channel_case.ex
│ └── conn_case.ex
│ └── test_helper.exs
└── run.sh
/.editorconfig:
--------------------------------------------------------------------------------
1 | # indicate this is the root of the project
2 |
3 | root = true
4 |
5 | [*.{kt,kts,java,xml,gradle,md}]
6 | charset = utf-8
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | end_of_line = lf
12 | max_line_length=80
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | #
4 | # These are explicitly windows files and should use crlf
5 | *.bat text eol=crlf
6 |
7 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Setup elixir
13 | uses: erlef/setup-beam@v1
14 | with:
15 | elixir-version: 1.12.2
16 | otp-version: 24
17 | - name: Run tests
18 | run: make test
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Gradle project-specific cache directory
2 | .gradle
3 |
4 | # Ignore Gradle build output directory
5 | build
6 |
7 | .envrc
8 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Nicolas Goy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MAKE.md:
--------------------------------------------------------------------------------
1 | # Makefile targets
2 |
3 | ## General
4 |
5 | - `help` print this message
6 |
7 | ## Build
8 |
9 | - `build` gradle build
10 | - `doc` publish documentation
11 |
12 | ## Test
13 |
14 | - `test` run tests
15 |
16 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | MDCAT:=$(firstword $(shell which mdcat cat 2>/dev/null))
2 |
3 | .PHONY: help
4 | help:
5 | $(MDCAT) MAKE.md
6 |
7 |
8 | .PHONY: build
9 | build:
10 | ./gradlew build -x test
11 |
12 | .PHONY: doc
13 | doc:
14 | rm -fr docs
15 | ./gradlew dokka
16 | mkdir -p docs
17 | mv build/docs/phoenix-channel/* docs/
18 | mv build/docs/style.css docs/
19 | for line in $$(find ./docs -name '*.html'); do sed -i 's/..\/style.css/style.css/g' $${line##* .}; done
20 |
21 | .PHONY: test
22 | test:
23 | ./src/test/run.sh
24 |
25 | .PHONY: clean
26 | clean:
27 | rm -fr build .gradle
28 |
29 | .PHONY: publish
30 | publish:
31 | ./gradlew -Psign publishMavenJavaPublicationToMavenRepository
32 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2 | import org.jetbrains.dokka.gradle.DokkaTask
3 |
4 | val projectGroup = "ch.kuon.phoenix"
5 | // Update elixir project (mock_servver:mix.exs) version too to keep them in sync
6 | // Also update version in README.md
7 | val projectVersion = "0.1.9"
8 | val projectName = "channel"
9 |
10 | plugins {
11 | // Apply the Kotlin JVM plugin to add support for Kotlin.
12 | id("org.jetbrains.kotlin.jvm") version "1.3.61"
13 |
14 | // Documentation generation
15 | id("org.jetbrains.dokka") version "0.10.0"
16 |
17 | // Apply the java-library plugin for API and implementation separation.
18 | `java-library`
19 |
20 | signing
21 |
22 | // Create maven artefacts
23 | `maven-publish`
24 | }
25 |
26 | repositories {
27 | // Use jcenter for resolving dependencies.
28 | // You can declare any Maven/Ivy/file repository here.
29 | jcenter()
30 | }
31 |
32 | dependencies {
33 | // Align versions of all Kotlin components
34 | implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
35 |
36 | // Use the Kotlin JDK 8 standard library.
37 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
38 |
39 | // Web Socket Client
40 | implementation("com.neovisionaries:nv-websocket-client:2.9")
41 |
42 | // JSON handling
43 | implementation("com.github.openjson:openjson:1.0.11")
44 |
45 | // Use the Kotlin test library.
46 | testImplementation("org.jetbrains.kotlin:kotlin-test")
47 |
48 | // Use the Kotlin JUnit integration.
49 | testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
50 |
51 | // Concurrent Unit test
52 | testImplementation("net.jodah:concurrentunit:0.4.6")
53 | }
54 |
55 |
56 | publishing {
57 | publications {
58 | create("mavenJava") {
59 | from(components["java"])
60 | groupId = projectGroup
61 | artifactId = projectName
62 | version = projectVersion
63 | }
64 | }
65 | repositories {
66 | maven {
67 | url = uri(layout.buildDirectory.dir("repo"))
68 | }
69 | }
70 | }
71 |
72 | signing {
73 | useGpgCmd()
74 | sign(publishing.publications["mavenJava"])
75 | }
76 |
77 |
78 | tasks.withType().configureEach {
79 | onlyIf { project.hasProperty("sign") as Boolean }
80 | }
81 |
82 | tasks {
83 | compileKotlin {
84 | kotlinOptions.allWarningsAsErrors = true
85 | }
86 | jar {
87 | archiveBaseName.set(projectName)
88 | archiveVersion.set(projectVersion)
89 | }
90 | withType {
91 | outputFormat = "html"
92 | outputDirectory = "build/docs/"
93 | configuration {
94 | moduleName = "phoenix-channel"
95 | includes = listOf("README.md")
96 | samples = listOf("src/test/kotlin/ch/kuon/phoenix/LibraryTest.kt")
97 | }
98 | }
99 | withType {
100 | kotlinOptions.jvmTarget = "1.8"
101 | }
102 | withType(Test::class.java) {
103 | testLogging.showStandardStreams = true
104 | }
105 | withType {
106 | destination = file("$buildDir/libs/${projectName}.pom")
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/docs/alltypes/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | alltypes - phoenix-channel
5 |
6 |
7 |
8 | All Types
9 |
10 |
11 |
12 |
13 | Phoenix channel client
14 |
15 |
16 |
17 | Exponential backoff timer
18 |
19 |
20 |
21 |
22 |
23 |
24 | Listen for presence changes
25 |
26 |
27 |
28 | Socket main constructor.
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/-c-l-o-s-e.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.CLOSE - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / CLOSE
9 |
10 | CLOSE
11 |
12 | CLOSE
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/-e-r-r-o-r.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.ERROR - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / ERROR
9 |
10 | ERROR
11 |
12 | ERROR
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/-j-o-i-n.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.JOIN - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / JOIN
9 |
10 | JOIN
11 |
12 | JOIN
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/-l-e-a-v-e.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.LEAVE - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / LEAVE
9 |
10 | LEAVE
11 |
12 | LEAVE
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/-r-e-p-l-y.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.REPLY - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / REPLY
9 |
10 | REPLY
11 |
12 | REPLY
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event.event - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event / event
9 |
10 | event
11 |
12 | var event : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-event/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Event - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Event
9 |
10 | Event
11 | enum class Event
12 | Channel built in events
13 | Enum Values
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 | Properties
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | var event : String
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-life-cycle-events.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.LifeCycleEvents - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / LifeCycleEvents
9 |
10 | LifeCycleEvents
11 |
12 | val LifeCycleEvents : List < String >
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message / <init>
9 |
10 | <init>
11 |
12 | Message ( )
13 | Channel messages
14 | Usually this class should not be created directly. It is
15 | used as a wrapper around response in Channel.on callback.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/get-error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message.getError - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message / getError
9 |
10 | getError
11 |
12 | open fun getError ( ) : String
13 | Returns the error reason.
14 | If this message is not an error, this will throw an exception
15 | so be sure to check Message.isError first.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message
9 |
10 | Message
11 | abstract class Message
12 | Channel messages
13 | Usually this class should not be created directly. It is
14 | used as a wrapper around response in Channel.on callback.
15 | Constructors
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Channel messages
24 | Message ( )
25 |
26 |
27 |
28 | Properties
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Response data from the server
37 | abstract val response : JSONObject
38 |
39 |
40 |
41 |
42 |
43 |
44 | Status of the response as sent by the server.
45 | abstract val status : String
46 |
47 |
48 |
49 | Functions
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | Returns the error reason.
58 | open fun getError ( ) : String
59 |
60 |
61 |
62 |
63 |
64 |
65 | Returns the error state of the message
66 | open fun isError ( ) : Boolean
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/is-error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message.isError - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message / isError
9 |
10 | isError
11 |
12 | open fun isError ( ) : Boolean
13 | Returns the error state of the message
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/response.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message.response - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message / response
9 |
10 | response
11 |
12 | abstract val response : JSONObject
13 | Response data from the server
14 | It can be an empty object if the response was empty, but never
15 | null
.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-message/status.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Message.status - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Message / status
9 |
10 | status
11 |
12 | abstract val status : String
13 | Status of the response as sent by the server.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-push/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Push. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Push / <init>
9 |
10 | <init>
11 |
12 | Push ( channel : Channel , event : String , payload : JSONObject , timeout : Int )
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-push/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Push - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Push
9 |
10 | Push
11 | class Push
12 | Constructors
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Push ( channel : Channel , event : String , payload : JSONObject , timeout : Int )
21 |
22 |
23 |
24 | Functions
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Register a callback when a message with the following
33 | status is returned.
34 | fun receive ( status : String , callback : ( JSONObject ) -> Unit ) : Push
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-push/receive.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.Push.receive - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / Push / receive
9 |
10 | receive
11 |
12 | fun receive ( status : String , callback : ( JSONObject ) -> Unit ) : Push
13 | Register a callback when a message with the following
14 | status is returned.
15 | Note: the callback might be called from another thread.
16 | Parameters
17 |
18 | status
- The status to register the callback for
19 |
20 | callback
- A callback called with the response
21 | Return
22 | Self for method chaining
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/-c-l-o-s-e-d.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.CLOSED - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / CLOSED
9 |
10 | CLOSED
11 |
12 | CLOSED
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/-e-r-r-o-r-e-d.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.ERRORED - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / ERRORED
9 |
10 | ERRORED
11 |
12 | ERRORED
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/-j-o-i-n-e-d.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.JOINED - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / JOINED
9 |
10 | JOINED
11 |
12 | JOINED
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/-j-o-i-n-i-n-g.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.JOINING - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / JOINING
9 |
10 | JOINING
11 |
12 | JOINING
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/-l-e-a-v-i-n-g.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.LEAVING - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / LEAVING
9 |
10 | LEAVING
11 |
12 | LEAVING
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State
9 |
10 | State
11 | enum class State
12 | Channel state
13 | Enum Values
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 | Properties
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | var state : String
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/-state/state.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.State.state - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / State / state
9 |
10 | state
11 |
12 | var state : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/join.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.join - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / join
9 |
10 | join
11 |
12 | fun join ( timeout : Int = this.timeout) : Push
13 | Join the channel.
14 | Parameters
15 |
16 | timeout
- Timeout in milliseconds,
17 | socket timeout will be used by default.
18 | Return
19 | A push that can be used to receive the messages returned
20 | by the server on the join.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/leave.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.leave - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / leave
9 |
10 | leave
11 |
12 | fun leave ( timeout : Int = this.timeout) : Push
13 | Leave a channel
14 | Parameters
15 |
16 | timeout
- TODO:description
17 |
18 | timeout
- Timeout, default to socket timeout
19 | Return
20 | A push that can be used for chaining
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/off.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.off - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / off
9 |
10 | off
11 |
12 | fun off ( event : String , ref : Ref ? = null) : Unit
13 | Unregister a callback
14 | Parameters
15 |
16 | event
- The event name to unregister the callback for.
17 | This must match what was passed to Channel.on .
18 |
19 | ref
- The ref returned by Channel.on , can be ommited
20 | to unregister all callbacks for a particular event.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/on-close.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.onClose - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / onClose
9 |
10 | onClose
11 |
12 | fun onClose ( callback : ( ) -> Unit ) : Ref
13 | Register a close callback
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | callback
- A callback called when the channel is closed
18 | Return
19 | A ref that can be used with Channel.off
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/on-error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.onError - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / onError
9 |
10 | onError
11 |
12 | fun onError ( callback : ( String ) -> Unit ) : Ref
13 | Register an error callback
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | callback
- A callback called when the channel has an error
18 | Return
19 | A ref that can be used with Channel.off
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/on.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.on - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / on
9 |
10 | on
11 |
12 | fun on ( event : String , callback : ( Message ) -> Unit ) : Ref
13 | Register a callback on arbitrary event
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | event
- The event to register the callback for
18 |
19 | callback
- A callback called when the channel receive a
20 | message for the given event
21 | Return
22 | A ref that can be used with Channel.off
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/params.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.params - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / params
9 |
10 | params
11 |
12 | var params : JSONObject
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/push.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.push - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / push
9 |
10 | push
11 |
12 | fun push ( event : String , payload : JSONObject = JSONObject(), timeout : Int = this.timeout) : Push
13 | Push a message to the channel.
14 | Parameters
15 |
16 | event
- Event name
17 |
18 | payload
- Arbitrary payload
19 |
20 | timeout
- Timeout, default to socket timeout
21 | Return
22 | A push that can be used for chaining
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/socket.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.socket - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / socket
9 |
10 | socket
11 |
12 | var socket : Socket
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/to-string.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.toString - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / toString
9 |
10 | toString
11 |
12 | fun toString ( ) : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-channel/topic.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Channel.topic - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Channel / topic
9 |
10 | topic
11 |
12 | var topic : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / <init>
9 |
10 | <init>
11 |
12 | ExTimer ( callback : Callback , timerCalc : ( Int ) -> Int )
13 | Exponential backoff timer
14 | Example from tests:
15 | val waiter = Waiter()
16 |
17 | var counter = 0
18 | val timer = ExTimer({
19 | counter++
20 | waiter.resume()
21 | }, { tries ->
22 | tries * 1000
23 | })
24 | // This is for the example, if you call
25 | // scheduleTimeout() in a row, the last call "wins"
26 | // This example will call the callback only once after
27 | // 4 seconds then once again after 1 second
28 | timer.scheduleTimeout() // fires after 1000
29 | timer.scheduleTimeout() // fires after 2000
30 | timer.scheduleTimeout() // fires after 3000
31 | timer.reset()
32 | timer.scheduleTimeout() // fires after 1000
33 | timer.scheduleTimeout() // fires after 2000
34 | timer.scheduleTimeout() // fires after 3000
35 | timer.scheduleTimeout() // fires after 4000
36 | waiter.await(5000, 1)
37 | waiter.assertEquals(1, counter)
38 |
39 | timer.reset()
40 | timer.scheduleTimeout() // fires after 1000
41 | waiter.await(2000, 1)
42 | waiter.assertEquals(2, counter)
43 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/callback.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.callback - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / callback
9 |
10 | callback
11 |
12 | var callback : Callback
13 | The function called when the timer fires
14 | Property
15 |
16 | callback
- The function called when the timer fires
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer
9 |
10 | ExTimer
11 | class ExTimer
12 | Exponential backoff timer
13 | Example from tests:
14 | val waiter = Waiter()
15 |
16 | var counter = 0
17 | val timer = ExTimer({
18 | counter++
19 | waiter.resume()
20 | }, { tries ->
21 | tries * 1000
22 | })
23 | // This is for the example, if you call
24 | // scheduleTimeout() in a row, the last call "wins"
25 | // This example will call the callback only once after
26 | // 4 seconds then once again after 1 second
27 | timer.scheduleTimeout() // fires after 1000
28 | timer.scheduleTimeout() // fires after 2000
29 | timer.scheduleTimeout() // fires after 3000
30 | timer.reset()
31 | timer.scheduleTimeout() // fires after 1000
32 | timer.scheduleTimeout() // fires after 2000
33 | timer.scheduleTimeout() // fires after 3000
34 | timer.scheduleTimeout() // fires after 4000
35 | waiter.await(5000, 1)
36 | waiter.assertEquals(1, counter)
37 |
38 | timer.reset()
39 | timer.scheduleTimeout() // fires after 1000
40 | waiter.await(2000, 1)
41 | waiter.assertEquals(2, counter)
42 | Constructors
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Exponential backoff timer
51 | ExTimer ( callback : Callback , timerCalc : ( Int ) -> Int )
52 |
53 |
54 |
55 | Properties
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | The function called when the timer fires
64 | var callback : Callback
65 |
66 |
67 |
68 |
69 |
70 |
71 | var timer : Timer ?
72 |
73 |
74 |
75 |
76 |
77 |
78 | A function that is called when the timer is scheduled.
79 | var timerCalc : ( Int ) -> Int
80 |
81 |
82 |
83 |
84 |
85 |
86 | var tries : AtomicInteger
87 |
88 |
89 |
90 | Functions
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | Reset the timeout and cancel the timer if it is scheduled.
99 | fun reset ( ) : Unit
100 |
101 |
102 |
103 |
104 |
105 |
106 | Schedule the timer to run once
107 | fun scheduleTimeout ( ) : Unit
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/reset.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.reset - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / reset
9 |
10 | reset
11 |
12 | fun reset ( ) : Unit
13 | Reset the timeout and cancel the timer if it is scheduled.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/schedule-timeout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.scheduleTimeout - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / scheduleTimeout
9 |
10 | scheduleTimeout
11 |
12 | fun scheduleTimeout ( ) : Unit
13 | Schedule the timer to run once
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/timer-calc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.timerCalc - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / timerCalc
9 |
10 | timerCalc
11 |
12 | var timerCalc : ( Int ) -> Int
13 | A function that is called when the timer is scheduled.
14 | It is called with the current try and must return a
15 | time in miliseconds.
16 | It is used to implement exponential timers.
17 | First value of tries
is 1.
18 | Property
19 |
20 | timerCalc
-
21 |
A function that is called when the timer is scheduled.
22 |
23 |
24 | It is called with the current try and must return a
25 | time in miliseconds.
26 |
27 |
28 | It is used to implement exponential timers.
29 |
30 |
31 | First value of tries
is 1.
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/timer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.timer - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / timer
9 |
10 | timer
11 |
12 | var timer : Timer ?
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-ex-timer/tries.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExTimer.tries - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / ExTimer / tries
9 |
10 | tries
11 |
12 | var tries : AtomicInteger
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / <init>
9 |
10 | <init>
11 |
12 | LibraryTest ( )
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest
9 |
10 | LibraryTest
11 | class LibraryTest
12 | Constructors
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | LibraryTest ( )
21 |
22 |
23 |
24 | Functions
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | fun testBroadcast ( ) : Unit
33 |
34 |
35 |
36 |
37 |
38 |
39 | fun testConnect ( ) : Unit
40 |
41 |
42 |
43 |
44 |
45 |
46 | fun testEcho ( ) : Unit
47 |
48 |
49 |
50 |
51 |
52 |
53 | fun testJoinError ( ) : Unit
54 |
55 |
56 |
57 |
58 |
59 |
60 | fun testPresence ( ) : Unit
61 |
62 |
63 |
64 |
65 |
66 |
67 | fun testTimer ( ) : Unit
68 |
69 |
70 |
71 |
72 |
73 |
74 | fun testURL ( ) : Unit
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-broadcast.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testBroadcast - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testBroadcast
9 |
10 | testBroadcast
11 |
12 | fun testBroadcast ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-connect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testConnect - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testConnect
9 |
10 | testConnect
11 |
12 | fun testConnect ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-echo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testEcho - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testEcho
9 |
10 | testEcho
11 |
12 | fun testEcho ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-join-error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testJoinError - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testJoinError
9 |
10 | testJoinError
11 |
12 | fun testJoinError ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-presence.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testPresence - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testPresence
9 |
10 | testPresence
11 |
12 | fun testPresence ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-timer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testTimer - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testTimer
9 |
10 | testTimer
11 |
12 | fun testTimer ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-library-test/test-u-r-l.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibraryTest.testURL - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / LibraryTest / testURL
9 |
10 | testURL
11 |
12 | fun testURL ( ) : Unit
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-entry/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Entry. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Entry / <init>
9 |
10 | <init>
11 |
12 | Entry ( rawData : String )
13 | A presence entry
14 | While presence are JSONObject subclasses, they should be considered
15 | immutable.
16 | Presence entries are returned by Presence.list and other callbacks.
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-entry/get-metas.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Entry.getMetas - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Entry / getMetas
9 |
10 | getMetas
11 |
12 | fun getMetas ( ) : JSONArray
13 | The presence meta data
14 | This is an arbitrary array and the format depends on your
15 | implementation.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-entry/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Entry - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Entry
9 |
10 | Entry
11 | class Entry : JSONObject
12 | A presence entry
13 | While presence are JSONObject subclasses, they should be considered
14 | immutable.
15 | Presence entries are returned by Presence.list and other callbacks.
16 | Constructors
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | A presence entry
25 | Entry ( rawData : String )
26 |
27 |
28 |
29 | Properties
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | The JSON string that sent by the server
38 | val rawData : String
39 |
40 |
41 |
42 | Functions
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | The presence meta data
51 | fun getMetas ( ) : JSONArray
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-entry/raw-data.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Entry.rawData - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Entry / rawData
9 |
10 | rawData
11 |
12 | val rawData : String
13 | The JSON string that sent by the server
14 | Property
15 |
16 | rawData
- The JSON string that sent by the server
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / <init>
9 |
10 | <init>
11 |
12 | Presence ( channel : Channel , opts : Options = Options())
13 | Listen for presence changes
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/-event-names/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options.EventNames. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / EventNames / <init>
9 |
10 | <init>
11 |
12 | EventNames ( state : String , diff : String )
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/-event-names/diff.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options.EventNames.diff - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / EventNames / diff
9 |
10 | diff
11 |
12 | val diff : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/-event-names/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options.EventNames - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / EventNames
9 |
10 | EventNames
11 | class EventNames
12 | Constructors
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | EventNames ( state : String , diff : String )
21 |
22 |
23 |
24 | Properties
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | val diff : String
33 |
34 |
35 |
36 |
37 |
38 |
39 | val state : String
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/-event-names/state.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options.EventNames.state - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / EventNames / state
9 |
10 | state
11 |
12 | val state : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / <init>
9 |
10 | <init>
11 |
12 | Options ( eventNames : EventNames = EventNames("presence_state", "presence_diff"))
13 | Presence options
14 | Default options should be used except for special requirements.
15 | They line up with phoenix default options.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/event-names.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options.eventNames - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options / eventNames
9 |
10 | eventNames
11 |
12 | var eventNames : EventNames
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/-options/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.Options - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / Options
9 |
10 | Options
11 | class Options
12 | Presence options
13 | Default options should be used except for special requirements.
14 | They line up with phoenix default options.
15 | Types
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | class EventNames
24 |
25 |
26 |
27 | Constructors
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | Presence options
36 | Options ( eventNames : EventNames = EventNames("presence_state", "presence_diff"))
37 |
38 |
39 |
40 | Properties
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | var eventNames : EventNames
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/channel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.channel - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / channel
9 |
10 | channel
11 |
12 | val channel : Channel
13 | A channel
14 | Property
15 |
16 | channel
- A channel
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/in-pending-sync-state.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.inPendingSyncState - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / inPendingSyncState
9 |
10 | inPendingSyncState
11 |
12 | fun inPendingSyncState ( ) : Boolean
13 | Is there any pendinng sync state
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.list - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / list
9 |
10 | list
11 |
12 | fun list ( by : ( String , Entry ) -> Entry = { _, p -> p }) : List < Entry >
13 | Returns the list of presence
14 | This method will return every presence returned by the server
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/on-join.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.onJoin - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / onJoin
9 |
10 | onJoin
11 |
12 | fun onJoin ( callback : ( key : String , currentPresence : Entry ? , newPresence : Entry ) -> Unit ) : Unit
13 | Set the callback for join event
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | callback
- The function to be called on join
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/on-leave.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.onLeave - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / onLeave
9 |
10 | onLeave
11 |
12 | fun onLeave ( callback : ( key : String , currentPresence : Entry ? , leftPresence : Entry ) -> Unit ) : Unit
13 | Set the callback for leave event
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | callback
- The function to be called on leave
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/on-sync.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.onSync - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / onSync
9 |
10 | onSync
11 |
12 | fun onSync ( callback : ( ) -> Unit ) : Unit
13 | Set the callback for sync event
14 | Note: the callback might be called on another thread
15 | Parameters
16 |
17 | callback
- The function to be called on sync
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-presence/opts.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Presence.opts - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Presence / opts
9 |
10 | opts
11 |
12 | val opts : Options
13 | Options
14 | Property
15 |
16 | opts
- Options
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / <init>
9 |
10 | <init>
11 |
12 | Socket ( url : String , opts : Options = Socket.Options())
13 | Socket main constructor.
14 | This class is a thin layer above websockets. This layer provides
15 | compatibility with Phoenix Sockets. It handle heartbeat, serialization and
16 | provides a simple event based API.
17 | When using Phoenix, you will usually not push messages directly to sockets
18 | but use Channels instead.
19 | The url can use either the ws://
or wss://
scheme.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / <init>
9 |
10 | <init>
11 |
12 | Message ( joinRef : Int ? = null, ref : Int ? = null, topic : String , event : String , payload : JSONObject = JSONObject())
13 | A raw socket message.
14 | This object is usually not created directly and Channel.Message
15 | is used instead.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.event - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / event
9 |
10 | event
11 |
12 | var event : String
13 | The event name
14 | Property
15 |
16 | event
- The event name
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message
9 |
10 | Message
11 | class Message
12 | A raw socket message.
13 | This object is usually not created directly and Channel.Message
14 | is used instead.
15 | Constructors
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | A raw socket message.
24 | Message ( joinRef : Int ? = null, ref : Int ? = null, topic : String , event : String , payload : JSONObject = JSONObject())
25 |
26 |
27 |
28 | Properties
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | The event name
37 | var event : String
38 |
39 |
40 |
41 |
42 |
43 |
44 | A join_ref
45 | var joinRef : Int ?
46 |
47 |
48 |
49 |
50 |
51 |
52 | A payload object
53 | var payload : JSONObject
54 |
55 |
56 |
57 |
58 |
59 |
60 | The ref
61 | var ref : Int ?
62 |
63 |
64 |
65 |
66 |
67 |
68 | The topic
69 | var topic : String
70 |
71 |
72 |
73 | Functions
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | fun toString ( ) : String
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/join-ref.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.joinRef - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / joinRef
9 |
10 | joinRef
11 |
12 | var joinRef : Int ?
13 | A join_ref
14 | Property
15 |
16 | joinRef
- A join_ref
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/payload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.payload - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / payload
9 |
10 | payload
11 |
12 | var payload : JSONObject
13 | A payload object
14 | Property
15 |
16 | payload
- A payload object
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/ref.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.ref - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / ref
9 |
10 | ref
11 |
12 | var ref : Int ?
13 | The ref
14 | Property
15 |
16 | ref
- The ref
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/to-string.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.toString - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / toString
9 |
10 | toString
11 |
12 | fun toString ( ) : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-message/topic.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Message.topic - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Message / topic
9 |
10 | topic
11 |
12 | var topic : String
13 | The topic
14 | Property
15 |
16 | topic
- The topic
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/-init-.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options. - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / <init>
9 |
10 | <init>
11 |
12 | Options ( )
13 | Socket options.
14 | Build the object with default constructor Options()
and
15 | customize it afterward.
16 | For interval function, look at ExTimer.timerCalc .
17 | Note: The logger callback might be called on other thread.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/heartbeat-interval-ms.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.heartbeatIntervalMs - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / heartbeatIntervalMs
9 |
10 | heartbeatIntervalMs
11 |
12 | var heartbeatIntervalMs : Long
13 | Heartbeat interval in miliseconds
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options
9 |
10 | Options
11 | class Options
12 | Socket options.
13 | Build the object with default constructor Options()
and
14 | customize it afterward.
15 | For interval function, look at ExTimer.timerCalc .
16 | Note: The logger callback might be called on other thread.
17 | Constructors
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Socket options.
26 | Options ( )
27 |
28 |
29 |
30 | Properties
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Heartbeat interval in miliseconds
39 | var heartbeatIntervalMs : Long
40 |
41 |
42 |
43 |
44 |
45 |
46 | Logger function (must be thread safe)
47 | var logger : ( ( String , String ) -> Unit ) ?
48 |
49 |
50 |
51 |
52 |
53 |
54 | A list of key/value sent with the conection.
55 | var params : HashMap < String , Any > ?
56 |
57 |
58 |
59 |
60 |
61 |
62 | Reconnect interval functions (must be thread safe)
63 | var reconnectAfterMs : ( Int ) -> Int
64 |
65 |
66 |
67 |
68 |
69 |
70 | Rejoin interval functions (must be thread safe)
71 | var rejoinAfterMs : ( Int ) -> Int
72 |
73 |
74 |
75 |
76 |
77 |
78 | Timeout in miliseconds
79 | var timeout : Int
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/logger.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.logger - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / logger
9 |
10 | logger
11 |
12 | var logger : ( ( String , String ) -> Unit ) ?
13 | Logger function (must be thread safe)
14 | Set to null to disable logging.
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/params.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.params - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / params
9 |
10 | params
11 |
12 | var params : HashMap < String , Any > ?
13 | A list of key/value sent with the conection.
14 | Those params are serialized to url parameters and appended to the
15 | connection url.
16 | For example passing mapOf("foo" to "bar")
will happend &foo=bar
17 | to the URL.
18 | toString()
is automaticall called on the values.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/reconnect-after-ms.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.reconnectAfterMs - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / reconnectAfterMs
9 |
10 | reconnectAfterMs
11 |
12 | var reconnectAfterMs : ( Int ) -> Int
13 | Reconnect interval functions (must be thread safe)
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/rejoin-after-ms.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.rejoinAfterMs - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / rejoinAfterMs
9 |
10 | rejoinAfterMs
11 |
12 | var rejoinAfterMs : ( Int ) -> Int
13 | Rejoin interval functions (must be thread safe)
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-options/timeout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.Options.timeout - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / Options / timeout
9 |
10 | timeout
11 |
12 | var timeout : Int
13 | Timeout in miliseconds
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-c-l-o-s-e-d.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.CLOSED - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / CLOSED
9 |
10 | CLOSED
11 |
12 | CLOSED
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-c-l-o-s-i-n-g.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.CLOSING - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / CLOSING
9 |
10 | CLOSING
11 |
12 | CLOSING
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-c-o-n-n-e-c-t-i-n-g.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.CONNECTING - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / CONNECTING
9 |
10 | CONNECTING
11 |
12 | CONNECTING
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-c-r-e-a-t-e-d.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.CREATED - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / CREATED
9 |
10 | CREATED
11 |
12 | CREATED
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-o-p-e-n.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.OPEN - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / OPEN
9 |
10 | OPEN
11 |
12 | OPEN
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/-u-n-k-n-o-w-n.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.UNKNOWN - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / UNKNOWN
9 |
10 | UNKNOWN
11 |
12 | UNKNOWN
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State
9 |
10 | State
11 | enum class State
12 | Enum representing socket state
13 | Enum Values
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 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Properties
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | var state : String
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/-state/state.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.State.state - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / State / state
9 |
10 | state
11 |
12 | var state : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/channel.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.channel - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / channel
9 |
10 | channel
11 |
12 | fun channel ( topic : String , params : JSONObject = JSONObject()) : Channel
13 | Prefered constructor for channels.
14 | Creates a channel and register it with the Socket.
15 | Parameters
16 |
17 | topic
- The channel topic
18 |
19 | params
- Params sent to the server on join
20 | Return
21 | The created channel
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/connect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.connect - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / connect
9 |
10 | connect
11 |
12 | fun connect ( ) : Unit
13 | Connect the socket to the server
14 |
15 |
16 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/connection-state.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.connectionState - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / connectionState
9 |
10 | connectionState
11 |
12 | fun connectionState ( ) : State
13 | Returns the current socket state
14 | Return
15 | The current state
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/disconnect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.disconnect - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / disconnect
9 |
10 | disconnect
11 |
12 | fun disconnect ( callback : ( ( ) -> Unit ) ? = null, code : Int ? = null, reason : String ? = null) : Unit
13 | Disconnect the socket.
14 | Note: The callback might be called on another thread
15 | Parameters
16 |
17 | callback
- Optional callback called after the socket is
18 | disconnected.
19 |
20 | code
- Send a disconnect code to the server
21 |
22 | reason
- Send a disconnect reason to the server
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/end-point-u-r-l.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.endPointURL - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / endPointURL
9 |
10 | endPointURL
11 |
12 | fun endPointURL ( ) : URI
13 | Returns the full endpoint URL.
14 | Phoenix requires /websocket
to be appended to the URL.
15 | vsn
is set to 2.0.0
for V2serializer
16 | Return
17 | URI The full endpoint URL.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/is-connected.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.isConnected - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / isConnected
9 |
10 | isConnected
11 |
12 | fun isConnected ( ) : Boolean
13 | Returns the connected state (if state is OPEN )
14 | Return
15 | True if state
16 | is OPEN , false otherwise
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/log.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.log - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / log
9 |
10 | log
11 |
12 | fun log ( tag : String , msg : String , data : Any ? = null) : Unit
13 | Log a message.
14 | Override logger
in Socket.Option to change this.
15 | Default to stdout
.
16 | Parameters
17 |
18 | tag
- Message tag
19 |
20 | msg
- Message
21 |
22 | data
- An object that will be appended to the message,
23 | toString()
will be called on data
.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/off.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.off - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / off
9 |
10 | off
11 |
12 | fun off ( refs : List < Ref > ) : Unit
13 | Unregister on listeners
14 | Parameters
15 |
16 | refs
- A list of references
17 |
18 | fun off ( ref : Ref ) : Unit
19 | Unregister on listener
20 | Parameters
21 |
22 | refs
- A single reference
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/on-close.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.onClose - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / onClose
9 |
10 | onClose
11 |
12 | fun onClose ( callback : CloseCallback ) : Ref
13 | Register an close callback.
14 | Multiple callbacks can be registerd.
15 | Note: The callback might be called on another thread
16 | Parameters
17 |
18 | callback
- A callback function
19 | Return
20 | A reference to the callback that can be used with the
21 | Socket.off function.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/on-error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.onError - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / onError
9 |
10 | onError
11 |
12 | fun onError ( callback : ErrorCallback ) : Ref
13 | Register an error callback.
14 | Multiple callbacks can be registerd.
15 | Note: The callback might be called on another thread
16 | Parameters
17 |
18 | callback
- A callback function
19 | Return
20 | A reference to the callback that can be used with the
21 | Socket.off function.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/on-message.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.onMessage - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / onMessage
9 |
10 | onMessage
11 |
12 | fun onMessage ( callback : MessageCallback ) : Ref
13 | Register an on message callback.
14 | Multiple callbacks can be registerd.
15 | Note: The callback might be called on another thread
16 | Parameters
17 |
18 | callback
- A callback function
19 | Return
20 | A reference to the callback that can be used with the
21 | Socket.off function.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/on-open.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.onOpen - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / onOpen
9 |
10 | onOpen
11 |
12 | fun onOpen ( callback : OpenCallback ) : Ref
13 | Register an open callback.
14 | Multiple callbacks can be registerd.
15 | Note: The callback might be called on another thread
16 | Parameters
17 |
18 | callback
- A callback function
19 | Return
20 | A reference to the callback that can be used with the
21 | Socket.off function.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/opts.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.opts - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / opts
9 |
10 | opts
11 |
12 | var opts : Options
13 | An Socket.Option
object. If ommited default configuration is
14 | used.
15 | Property
16 |
17 | opts
- An Socket.Option
object. If ommited default configuration is
18 | used.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/push.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.push - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / push
9 |
10 | push
11 |
12 | fun push ( msg : Message ) : Unit
13 | Push a message to the socket
14 | Parameters
15 |
16 | msg
- A message
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/to-string.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.toString - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / toString
9 |
10 | toString
11 |
12 | fun toString ( ) : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/-socket/url.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Socket.url - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / Socket / url
9 |
10 | url
11 |
12 | var url : String
13 | The full web socket URL
14 | Property
15 |
16 | url
- The full web socket URL
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ch.kuon.phoenix - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix
9 |
10 | Package ch.kuon.phoenix
11 | Types
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Phoenix channel client
20 | class Channel
21 |
22 |
23 |
24 |
25 |
26 |
27 | Exponential backoff timer
28 | class ExTimer
29 |
30 |
31 |
32 |
33 |
34 |
35 | class LibraryTest
36 |
37 |
38 |
39 |
40 |
41 |
42 | Listen for presence changes
43 | class Presence
44 |
45 |
46 |
47 |
48 |
49 |
50 | Socket main constructor.
51 | class Socket : WebSocketAdapter
52 |
53 |
54 |
55 | Properties
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | val url : String
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/docs/ch.kuon.phoenix/url.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | url - phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel / ch.kuon.phoenix / url
9 |
10 | url
11 |
12 | val url : String
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | phoenix-channel
5 |
6 |
7 |
8 | phoenix-channel
9 |
10 | Packages
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Index
23 | All Types
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/package-list:
--------------------------------------------------------------------------------
1 | $dokka.format:html
2 | $dokka.linkExtension:html
3 |
4 | ch.kuon.phoenix
5 |
--------------------------------------------------------------------------------
/docs/style.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Open+Sans:300i,400,700);
2 |
3 | body, table {
4 | padding:50px;
5 | font:14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
6 | color:#555;
7 | font-weight:300;
8 | margin-left: auto;
9 | margin-right: auto;
10 | max-width: 1440px;
11 | }
12 |
13 | .keyword {
14 | color:black;
15 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
16 | font-size:12px;
17 | }
18 |
19 | .symbol {
20 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
21 | font-size:12px;
22 | }
23 |
24 | .identifier {
25 | color: darkblue;
26 | font-size:12px;
27 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
28 | }
29 |
30 | h1, h2, h3, h4, h5, h6 {
31 | color:#222;
32 | margin:0 0 20px;
33 | }
34 |
35 | p, ul, ol, table, pre, dl {
36 | margin:0 0 20px;
37 | }
38 |
39 | h1, h2, h3 {
40 | line-height:1.1;
41 | }
42 |
43 | h1 {
44 | font-size:28px;
45 | }
46 |
47 | h2 {
48 | color:#393939;
49 | }
50 |
51 | h3, h4, h5, h6 {
52 | color:#494949;
53 | }
54 |
55 | a {
56 | color:#258aaf;
57 | font-weight:400;
58 | text-decoration:none;
59 | }
60 |
61 | a:hover {
62 | color: inherit;
63 | text-decoration:underline;
64 | }
65 |
66 | a small {
67 | font-size:11px;
68 | color:#555;
69 | margin-top:-0.6em;
70 | display:block;
71 | }
72 |
73 | .wrapper {
74 | width:860px;
75 | margin:0 auto;
76 | }
77 |
78 | blockquote {
79 | border-left:1px solid #e5e5e5;
80 | margin:0;
81 | padding:0 0 0 20px;
82 | font-style:italic;
83 | }
84 |
85 | code, pre {
86 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
87 | color:#333;
88 | font-size:12px;
89 | }
90 |
91 | pre {
92 | display: block;
93 | /*
94 | padding:8px 8px;
95 | background: #f8f8f8;
96 | border-radius:5px;
97 | border:1px solid #e5e5e5;
98 | */
99 | overflow-x: auto;
100 | }
101 |
102 | table {
103 | width:100%;
104 | border-collapse:collapse;
105 | }
106 |
107 | th, td {
108 | text-align:left;
109 | vertical-align: top;
110 | padding:5px 10px;
111 | }
112 |
113 | dt {
114 | color:#444;
115 | font-weight:700;
116 | }
117 |
118 | th {
119 | color:#444;
120 | }
121 |
122 | img {
123 | max-width:100%;
124 | }
125 |
126 | header {
127 | width:270px;
128 | float:left;
129 | position:fixed;
130 | }
131 |
132 | header ul {
133 | list-style:none;
134 | height:40px;
135 |
136 | padding:0;
137 |
138 | background: #eee;
139 | background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
140 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
141 | background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
142 | background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
143 | background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
144 | background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
145 |
146 | border-radius:5px;
147 | border:1px solid #d2d2d2;
148 | box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
149 | width:270px;
150 | }
151 |
152 | header li {
153 | width:89px;
154 | float:left;
155 | border-right:1px solid #d2d2d2;
156 | height:40px;
157 | }
158 |
159 | header ul a {
160 | line-height:1;
161 | font-size:11px;
162 | color:#999;
163 | display:block;
164 | text-align:center;
165 | padding-top:6px;
166 | height:40px;
167 | }
168 |
169 | strong {
170 | color:#222;
171 | font-weight:700;
172 | }
173 |
174 | header ul li + li {
175 | width:88px;
176 | border-left:1px solid #fff;
177 | }
178 |
179 | header ul li + li + li {
180 | border-right:none;
181 | width:89px;
182 | }
183 |
184 | header ul a strong {
185 | font-size:14px;
186 | display:block;
187 | color:#222;
188 | }
189 |
190 | section {
191 | width:500px;
192 | float:right;
193 | padding-bottom:50px;
194 | }
195 |
196 | small {
197 | font-size:11px;
198 | }
199 |
200 | hr {
201 | border:0;
202 | background:#e5e5e5;
203 | height:1px;
204 | margin:0 0 20px;
205 | }
206 |
207 | footer {
208 | width:270px;
209 | float:left;
210 | position:fixed;
211 | bottom:50px;
212 | }
213 |
214 | @media print, screen and (max-width: 960px) {
215 |
216 | div.wrapper {
217 | width:auto;
218 | margin:0;
219 | }
220 |
221 | header, section, footer {
222 | float:none;
223 | position:static;
224 | width:auto;
225 | }
226 |
227 | header {
228 | padding-right:320px;
229 | }
230 |
231 | section {
232 | border:1px solid #e5e5e5;
233 | border-width:1px 0;
234 | padding:20px 0;
235 | margin:0 0 20px;
236 | }
237 |
238 | header a small {
239 | display:inline;
240 | }
241 |
242 | header ul {
243 | position:absolute;
244 | right:50px;
245 | top:52px;
246 | }
247 | }
248 |
249 | @media print, screen and (max-width: 720px) {
250 | body {
251 | word-wrap:break-word;
252 | }
253 |
254 | header {
255 | padding:0;
256 | }
257 |
258 | header ul, header p.view {
259 | position:static;
260 | }
261 |
262 | pre, code {
263 | word-wrap:normal;
264 | }
265 | }
266 |
267 | @media print, screen and (max-width: 480px) {
268 | body {
269 | padding:15px;
270 | }
271 |
272 | header ul {
273 | display:none;
274 | }
275 | }
276 |
277 | @media print {
278 | body {
279 | padding:0.4in;
280 | font-size:12pt;
281 | color:#444;
282 | }
283 | }
284 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuon/java-phoenix-channel/b49f397f1f3e40eb421e0272cb0c2563059b3721/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=`expr $i + 1`
158 | done
159 | case $i in
160 | 0) set -- ;;
161 | 1) set -- "$args0" ;;
162 | 2) set -- "$args0" "$args1" ;;
163 | 3) set -- "$args0" "$args1" "$args2" ;;
164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=`save "$@"`
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | exec "$JAVACMD" "$@"
184 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | *
4 | * The settings file is used to specify which projects to include in your build.
5 | *
6 | * Detailed information about configuring a multi-project build in Gradle can be found
7 | * in the user manual at https://docs.gradle.org/6.1.1/userguide/multi_project_builds.html
8 | */
9 |
10 | rootProject.name = "java-phoenix-channel"
11 |
--------------------------------------------------------------------------------
/src/main/kotlin/ch/kuon/phoenix/ExTimer.kt:
--------------------------------------------------------------------------------
1 | package ch.kuon.phoenix
2 |
3 | import kotlin.concurrent.schedule
4 | import java.util.Timer
5 | import java.util.concurrent.atomic.AtomicInteger
6 |
7 | /**
8 | *
9 | * Exponential backoff timer
10 | *
11 | * Example from tests:
12 | *
13 | * @sample LibraryTest.testTimer
14 | * @property callback The function called when the timer fires
15 | * @property timerCalc A function that is called when the timer is scheduled.
16 | *
17 | * It is called with the current try and must return a
18 | * time in miliseconds.
19 | *
20 | * It is used to implement exponential timers.
21 | *
22 | * First value of `tries` is 1.
23 | */
24 | class ExTimer(var callback: Callback, var timerCalc: (Int) -> Int) {
25 |
26 | var timer: Timer? = null
27 | var tries = AtomicInteger()
28 |
29 | /**
30 | * Reset the timeout and cancel the timer if it is scheduled.
31 | */
32 | fun reset() {
33 | tries.set(0)
34 | timer?.cancel()
35 | timer = null
36 | }
37 |
38 | /**
39 | * Schedule the timer to run once
40 | */
41 | fun scheduleTimeout() {
42 | timer?.cancel()
43 |
44 | timer = Timer()
45 |
46 | timer?.schedule(timerCalc(tries.get() + 1).toLong()) {
47 | tries.incrementAndGet()
48 | callback()
49 | }
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/src/test/mock_server/.formatter.exs:
--------------------------------------------------------------------------------
1 | [
2 | import_deps: [:phoenix],
3 | inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"],
4 | line_length: 80
5 | ]
6 |
--------------------------------------------------------------------------------
/src/test/mock_server/.gitignore:
--------------------------------------------------------------------------------
1 | # The directory Mix will write compiled artifacts to.
2 | /_build/
3 |
4 | # If you run "mix test --cover", coverage assets end up here.
5 | /cover/
6 |
7 | # The directory Mix downloads your dependencies sources to.
8 | /deps/
9 |
10 | # Where 3rd-party dependencies like ExDoc output generated docs.
11 | /doc/
12 |
13 | # Ignore .fetch files in case you like to edit your project deps locally.
14 | /.fetch
15 |
16 | # If the VM crashes, it generates a dump, let's ignore it too.
17 | erl_crash.dump
18 |
19 | # Also ignore archive artifacts (built via "mix archive.build").
20 | *.ez
21 |
22 | # Ignore package tarball (built via "mix hex.build").
23 | mock_server-*.tar
24 |
25 | # Since we are building assets from assets/,
26 | # we ignore priv/static. You may want to comment
27 | # this depending on your deployment strategy.
28 | /priv/static/
29 |
--------------------------------------------------------------------------------
/src/test/mock_server/README.md:
--------------------------------------------------------------------------------
1 | # MockServer
2 |
3 | To start your Phoenix server:
4 |
5 | * Install dependencies with `mix deps.get`
6 | * Start Phoenix endpoint with `mix phx.server`
7 |
8 | Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
9 |
10 | Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).
11 |
12 | ## Learn more
13 |
14 | * Official website: http://www.phoenixframework.org/
15 | * Guides: https://hexdocs.pm/phoenix/overview.html
16 | * Docs: https://hexdocs.pm/phoenix
17 | * Mailing list: http://groups.google.com/group/phoenix-talk
18 | * Source: https://github.com/phoenixframework/phoenix
19 |
--------------------------------------------------------------------------------
/src/test/mock_server/config/config.exs:
--------------------------------------------------------------------------------
1 | # This file is responsible for configuring your application
2 | # and its dependencies with the aid of the Mix.Config module.
3 | #
4 | # This configuration file is loaded before any dependency and
5 | # is restricted to this project.
6 |
7 | # General application configuration
8 | use Mix.Config
9 |
10 | # Configures the endpoint
11 | config :mock_server, MockServerWeb.Endpoint,
12 | url: [host: "localhost"],
13 | secret_key_base:
14 | "iCmRSF4xTTt+gJkmbgUFV0c2LPf1/F48AQI7TSkmR+eVy8GOY8tQJk3ErHB7JDYt",
15 | render_errors: [view: MockServerWeb.ErrorView, accepts: ~w(json)],
16 | pubsub: [name: MockServer.PubSub, adapter: Phoenix.PubSub.PG2]
17 |
18 | # Configures Elixir's Logger
19 | config :logger, :console,
20 | format: "$time $metadata[$level] $message\n",
21 | metadata: [:request_id]
22 |
23 | # Use Jason for JSON parsing in Phoenix
24 | config :phoenix, :json_library, Jason
25 |
26 | # Import environment specific config. This must remain at the bottom
27 | # of this file so it overrides the configuration defined above.
28 | import_config "#{Mix.env()}.exs"
29 |
--------------------------------------------------------------------------------
/src/test/mock_server/config/dev.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # For development, we disable any cache and enable
4 | # debugging and code reloading.
5 | #
6 | # The watchers configuration can be used to run external
7 | # watchers to your application. For example, we use it
8 | # with webpack to recompile .js and .css sources.
9 | config :mock_server, MockServerWeb.Endpoint,
10 | http: [port: 4444],
11 | debug_errors: true,
12 | code_reloader: true,
13 | check_origin: false,
14 | watchers: []
15 |
16 | # ## SSL Support
17 | #
18 | # In order to use HTTPS in development, a self-signed
19 | # certificate can be generated by running the following
20 | # Mix task:
21 | #
22 | # mix phx.gen.cert
23 | #
24 | # Note that this task requires Erlang/OTP 20 or later.
25 | # Run `mix help phx.gen.cert` for more information.
26 | #
27 | # The `http:` config above can be replaced with:
28 | #
29 | # https: [
30 | # port: 4001,
31 | # cipher_suite: :strong,
32 | # keyfile: "priv/cert/selfsigned_key.pem",
33 | # certfile: "priv/cert/selfsigned.pem"
34 | # ],
35 | #
36 | # If desired, both `http:` and `https:` keys can be
37 | # configured to run both http and https servers on
38 | # different ports.
39 |
40 | # Do not include metadata nor timestamps in development logs
41 | config :logger, :console, format: "[$level] $message\n"
42 |
43 | # Set a higher stacktrace during development. Avoid configuring such
44 | # in production as building large stacktraces may be expensive.
45 | config :phoenix, :stacktrace_depth, 20
46 |
47 | # Initialize plugs at runtime for faster development compilation
48 | config :phoenix, :plug_init_mode, :runtime
49 |
--------------------------------------------------------------------------------
/src/test/mock_server/config/prod.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # For production, don't forget to configure the url host
4 | # to something meaningful, Phoenix uses this information
5 | # when generating URLs.
6 | #
7 | # Note we also include the path to a cache manifest
8 | # containing the digested version of static files. This
9 | # manifest is generated by the `mix phx.digest` task,
10 | # which you should run after static files are built and
11 | # before starting your production server.
12 | config :mock_server, MockServerWeb.Endpoint,
13 | url: [host: "example.com", port: 80],
14 | cache_static_manifest: "priv/static/cache_manifest.json"
15 |
16 | # Do not print debug messages in production
17 | config :logger, level: :info
18 |
19 | # ## SSL Support
20 | #
21 | # To get SSL working, you will need to add the `https` key
22 | # to the previous section and set your `:url` port to 443:
23 | #
24 | # config :mock_server, MockServerWeb.Endpoint,
25 | # ...
26 | # url: [host: "example.com", port: 443],
27 | # https: [
28 | # :inet6,
29 | # port: 443,
30 | # cipher_suite: :strong,
31 | # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
32 | # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
33 | # ]
34 | #
35 | # The `cipher_suite` is set to `:strong` to support only the
36 | # latest and more secure SSL ciphers. This means old browsers
37 | # and clients may not be supported. You can set it to
38 | # `:compatible` for wider support.
39 | #
40 | # `:keyfile` and `:certfile` expect an absolute path to the key
41 | # and cert in disk or a relative path inside priv, for example
42 | # "priv/ssl/server.key". For all supported SSL configuration
43 | # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
44 | #
45 | # We also recommend setting `force_ssl` in your endpoint, ensuring
46 | # no data is ever sent via http, always redirecting to https:
47 | #
48 | # config :mock_server, MockServerWeb.Endpoint,
49 | # force_ssl: [hsts: true]
50 | #
51 | # Check `Plug.SSL` for all available options in `force_ssl`.
52 |
53 | # Finally import the config/prod.secret.exs which loads secrets
54 | # and configuration from environment variables.
55 | import_config "prod.secret.exs"
56 |
--------------------------------------------------------------------------------
/src/test/mock_server/config/prod.secret.exs:
--------------------------------------------------------------------------------
1 | # In this file, we load production configuration and secrets
2 | # from environment variables. You can also hardcode secrets,
3 | # although such is generally not recommended and you have to
4 | # remember to add this file to your .gitignore.
5 | use Mix.Config
6 |
7 | secret_key_base =
8 | System.get_env("SECRET_KEY_BASE") ||
9 | raise """
10 | environment variable SECRET_KEY_BASE is missing.
11 | You can generate one by calling: mix phx.gen.secret
12 | """
13 |
14 | config :mock_server, MockServerWeb.Endpoint,
15 | http: [:inet6, port: String.to_integer(System.get_env("PORT") || "4000")],
16 | secret_key_base: secret_key_base
17 |
18 | # ## Using releases (Elixir v1.9+)
19 | #
20 | # If you are doing OTP releases, you need to instruct Phoenix
21 | # to start each relevant endpoint:
22 | #
23 | # config :mock_server, MockServerWeb.Endpoint, server: true
24 | #
25 | # Then you can assemble a release by calling `mix release`.
26 | # See `mix help release` for more information.
27 |
--------------------------------------------------------------------------------
/src/test/mock_server/config/test.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # We don't run a server during test. If one is required,
4 | # you can enable the server option below.
5 | config :mock_server, MockServerWeb.Endpoint,
6 | http: [port: 4002],
7 | server: false
8 |
9 | # Print only warnings and errors during test
10 | config :logger, level: :warn
11 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServer do
2 | @moduledoc """
3 | MockServer keeps the contexts that define your domain
4 | and business logic.
5 |
6 | Contexts are also responsible for managing your data, regardless
7 | if it comes from the database, an external API or others.
8 | """
9 | end
10 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server/application.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServer.Application do
2 | # See https://hexdocs.pm/elixir/Application.html
3 | # for more information on OTP Applications
4 | @moduledoc false
5 |
6 | use Application
7 |
8 | def start(_type, _args) do
9 | # List all child processes to be supervised
10 | children = [
11 | # Start the endpoint when the application starts
12 | MockServerWeb.Endpoint,
13 | MockServerWeb.MockPresence,
14 | MockServer.Counter,
15 | ]
16 |
17 | # See https://hexdocs.pm/elixir/Supervisor.html
18 | # for other strategies and supported options
19 | opts = [strategy: :one_for_one, name: MockServer.Supervisor]
20 | Supervisor.start_link(children, opts)
21 | end
22 |
23 | # Tell Phoenix to update the endpoint configuration
24 | # whenever the application is updated.
25 | def config_change(changed, _new, removed) do
26 | MockServerWeb.Endpoint.config_change(changed, removed)
27 | :ok
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server/counter.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServer.Counter do
2 | use Agent
3 |
4 | def start_link(_) do
5 | Agent.start_link(fn -> 0 end, name: __MODULE__)
6 | end
7 |
8 | def value do
9 | Agent.get(__MODULE__, & &1)
10 | end
11 |
12 | def increment do
13 | Agent.get_and_update(__MODULE__, &({&1, &1 + 1}))
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb do
2 | @moduledoc """
3 | The entrypoint for defining your web interface, such
4 | as controllers, views, channels and so on.
5 |
6 | This can be used in your application as:
7 |
8 | use MockServerWeb, :controller
9 | use MockServerWeb, :view
10 |
11 | The definitions below will be executed for every view,
12 | controller, etc, so keep them short and clean, focused
13 | on imports, uses and aliases.
14 |
15 | Do NOT define functions inside the quoted expressions
16 | below. Instead, define any helper function in modules
17 | and import those modules here.
18 | """
19 |
20 | def controller do
21 | quote do
22 | use Phoenix.Controller, namespace: MockServerWeb
23 |
24 | import Plug.Conn
25 | import MockServerWeb.Gettext
26 | alias MockServerWeb.Router.Helpers, as: Routes
27 | end
28 | end
29 |
30 | def view do
31 | quote do
32 | use Phoenix.View,
33 | root: "lib/mock_server_web/templates",
34 | namespace: MockServerWeb
35 |
36 | # Import convenience functions from controllers
37 | import Phoenix.Controller,
38 | only: [get_flash: 1, get_flash: 2, view_module: 1]
39 |
40 | import MockServerWeb.ErrorHelpers
41 | import MockServerWeb.Gettext
42 | alias MockServerWeb.Router.Helpers, as: Routes
43 | end
44 | end
45 |
46 | def router do
47 | quote do
48 | use Phoenix.Router
49 | import Plug.Conn
50 | import Phoenix.Controller
51 | end
52 | end
53 |
54 | def channel do
55 | quote do
56 | use Phoenix.Channel
57 | import MockServerWeb.Gettext
58 | end
59 | end
60 |
61 | @doc """
62 | When used, dispatch to the appropriate controller/view/etc.
63 | """
64 | defmacro __using__(which) when is_atom(which) do
65 | apply(__MODULE__, which, [])
66 | end
67 | end
68 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/channels/mock_channel.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.MockChannel do
2 | use MockServerWeb, :channel
3 |
4 | alias MockServerWeb.MockPresence, as: Presence
5 | alias MockServer.Counter
6 |
7 |
8 | def join("mock:lobby", payload, socket) do
9 | if authorized?(payload) do
10 | {:ok, %{mock: "mockdata"}, socket}
11 | else
12 | {:error, %{reason: "unauthorized"}}
13 | end
14 | end
15 |
16 | def join("mock:presence", _payload, socket) do
17 | send(self(), :after_join)
18 | {:ok, assign(socket, :user_id, Counter.increment())}
19 | end
20 |
21 | def handle_in("echo", payload, socket) do
22 | {:reply, {:ok, payload}, socket}
23 | end
24 |
25 | def handle_in("echo_error", _payload, socket) do
26 | {:reply, {:error, "bogus data"}, socket}
27 | end
28 |
29 | def handle_in("trigger", payload, socket) do
30 | broadcast(socket, "broadcast", payload)
31 | {:noreply, socket}
32 | end
33 |
34 | # Add authorization logic here as required.
35 | defp authorized?(%{"auth" => "secret"}), do: true
36 | defp authorized?(_), do: false
37 |
38 | def handle_info(:after_join, socket) do
39 | push(socket, "presence_state", Presence.list(socket))
40 |
41 | {:ok, _} =
42 | Presence.track(socket, socket.assigns.user_id, %{
43 | online_at: inspect(System.system_time(:second))
44 | })
45 |
46 | {:noreply, socket}
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/channels/mock_presence.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.MockPresence do
2 | @moduledoc """
3 | Provides presence tracking to channels and processes.
4 |
5 | See the [`Phoenix.Presence`](http://hexdocs.pm/phoenix/Phoenix.Presence.html)
6 | docs for more details.
7 |
8 | ## Usage
9 |
10 | Presences can be tracked in your channel after joining:
11 |
12 | defmodule MockServer.MyChannel do
13 | use MockServerWeb, :channel
14 | alias MockServerWeb.Presence
15 |
16 | def join("some:topic", _params, socket) do
17 | send(self(), :after_join)
18 | {:ok, assign(socket, :user_id, ...)}
19 | end
20 |
21 | def handle_info(:after_join, socket) do
22 | push(socket, "presence_state", Presence.list(socket))
23 | {:ok, _} = Presence.track(socket, socket.assigns.user_id, %{
24 | online_at: inspect(System.system_time(:second))
25 | })
26 | {:noreply, socket}
27 | end
28 | end
29 |
30 | In the example above, `Presence.track` is used to register this
31 | channel's process as a presence for the socket's user ID, with
32 | a map of metadata. Next, the current presence list for
33 | the socket's topic is pushed to the client as a `"presence_state"` event.
34 |
35 | Finally, a diff of presence join and leave events will be sent to the
36 | client as they happen in real-time with the "presence_diff" event.
37 | See `Phoenix.Presence.list/2` for details on the presence data structure.
38 |
39 | ## Fetching Presence Information
40 |
41 | The `fetch/2` callback is triggered when using `list/1`
42 | and serves as a mechanism to fetch presence information a single time,
43 | before broadcasting the information to all channel subscribers.
44 | This prevents N query problems and gives you a single place to group
45 | isolated data fetching to extend presence metadata.
46 |
47 | The function receives a topic and map of presences and must return a
48 | map of data matching the Presence data structure:
49 |
50 | %{"123" => %{metas: [%{status: "away", phx_ref: ...}],
51 | "456" => %{metas: [%{status: "online", phx_ref: ...}]}
52 |
53 | The `:metas` key must be kept, but you can extend the map of information
54 | to include any additional information. For example:
55 |
56 | def fetch(_topic, entries) do
57 | users = entries |> Map.keys() |> Accounts.get_users_map(entries)
58 | # => %{"123" => %{name: "User 123"}, "456" => %{name: nil}}
59 |
60 | for {key, %{metas: metas}} <- entries, into: %{} do
61 | {key, %{metas: metas, user: users[key]}}
62 | end
63 | end
64 |
65 | The function above fetches all users from the database who
66 | have registered presences for the given topic. The fetched
67 | information is then extended with a `:user` key of the user's
68 | information, while maintaining the required `:metas` field from the
69 | original presence data.
70 | """
71 | use Phoenix.Presence,
72 | otp_app: :mock_server,
73 | pubsub_server: MockServer.PubSub
74 |
75 |
76 | def fetch(_topic, entries) do
77 | for {key, %{metas: metas}} <- entries, into: %{} do
78 | {key, %{metas: metas, user: key}}
79 | end
80 | end
81 | end
82 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/channels/user_socket.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.UserSocket do
2 | use Phoenix.Socket
3 |
4 | ## Channels
5 | # channel "room:*", MockServerWeb.RoomChannel
6 | #
7 | channel "mock:*", MockServerWeb.MockChannel
8 |
9 | # Socket params are passed from the client and can
10 | # be used to verify and authenticate a user. After
11 | # verification, you can put default assigns into
12 | # the socket that will be set for all channels, ie
13 | #
14 | # {:ok, assign(socket, :user_id, verified_user_id)}
15 | #
16 | # To deny connection, return `:error`.
17 | #
18 | # See `Phoenix.Token` documentation for examples in
19 | # performing token verification on connect.
20 | def connect(_params, socket, _connect_info) do
21 | {:ok, socket}
22 | end
23 |
24 | # Socket id's are topics that allow you to identify all sockets for a given user:
25 | #
26 | # def id(socket), do: "user_socket:#{socket.assigns.user_id}"
27 | #
28 | # Would allow you to broadcast a "disconnect" event and terminate
29 | # all active sockets and channels for a given user:
30 | #
31 | # MockServerWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
32 | #
33 | # Returning `nil` makes this socket anonymous.
34 | def id(_socket), do: nil
35 | end
36 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/endpoint.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.Endpoint do
2 | use Phoenix.Endpoint, otp_app: :mock_server
3 |
4 | socket "/socket", MockServerWeb.UserSocket,
5 | websocket: true,
6 | longpoll: false
7 |
8 | # Serve at "/" the static files from "priv/static" directory.
9 | #
10 | # You should set gzip to true if you are running phx.digest
11 | # when deploying your static files in production.
12 | plug Plug.Static,
13 | at: "/",
14 | from: :mock_server,
15 | gzip: false,
16 | only: ~w(css fonts images js favicon.ico robots.txt)
17 |
18 | # Code reloading can be explicitly enabled under the
19 | # :code_reloader configuration of your endpoint.
20 | if code_reloading? do
21 | plug Phoenix.CodeReloader
22 | end
23 |
24 | plug Plug.RequestId
25 | plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
26 |
27 | plug Plug.Parsers,
28 | parsers: [:urlencoded, :multipart, :json],
29 | pass: ["*/*"],
30 | json_decoder: Phoenix.json_library()
31 |
32 | plug Plug.MethodOverride
33 | plug Plug.Head
34 |
35 | # The session will be stored in the cookie and signed,
36 | # this means its contents can be read but not tampered with.
37 | # Set :encryption_salt if you would also like to encrypt it.
38 | plug Plug.Session,
39 | store: :cookie,
40 | key: "_mock_server_key",
41 | signing_salt: "I2ilaEZ+"
42 |
43 | plug MockServerWeb.Router
44 | end
45 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/gettext.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.Gettext do
2 | @moduledoc """
3 | A module providing Internationalization with a gettext-based API.
4 |
5 | By using [Gettext](https://hexdocs.pm/gettext),
6 | your module gains a set of macros for translations, for example:
7 |
8 | import MockServerWeb.Gettext
9 |
10 | # Simple translation
11 | gettext("Here is the string to translate")
12 |
13 | # Plural translation
14 | ngettext("Here is the string to translate",
15 | "Here are the strings to translate",
16 | 3)
17 |
18 | # Domain-based translation
19 | dgettext("errors", "Here is the error message to translate")
20 |
21 | See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
22 | """
23 | use Gettext, otp_app: :mock_server
24 | end
25 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/router.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.Router do
2 | use MockServerWeb, :router
3 |
4 | pipeline :api do
5 | plug :accepts, ["json"]
6 | end
7 |
8 | scope "/api", MockServerWeb do
9 | pipe_through :api
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/views/error_helpers.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.ErrorHelpers do
2 | @moduledoc """
3 | Conveniences for translating and building error messages.
4 | """
5 |
6 | @doc """
7 | Translates an error message using gettext.
8 | """
9 | def translate_error({msg, opts}) do
10 | # When using gettext, we typically pass the strings we want
11 | # to translate as a static argument:
12 | #
13 | # # Translate "is invalid" in the "errors" domain
14 | # dgettext("errors", "is invalid")
15 | #
16 | # # Translate the number of files with plural rules
17 | # dngettext("errors", "1 file", "%{count} files", count)
18 | #
19 | # Because the error messages we show in our forms and APIs
20 | # are defined inside Ecto, we need to translate them dynamically.
21 | # This requires us to call the Gettext module passing our gettext
22 | # backend as first argument.
23 | #
24 | # Note we use the "errors" domain, which means translations
25 | # should be written to the errors.po file. The :count option is
26 | # set by Ecto and indicates we should also apply plural rules.
27 | if count = opts[:count] do
28 | Gettext.dngettext(MockServerWeb.Gettext, "errors", msg, msg, count, opts)
29 | else
30 | Gettext.dgettext(MockServerWeb.Gettext, "errors", msg, opts)
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/src/test/mock_server/lib/mock_server_web/views/error_view.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.ErrorView do
2 | use MockServerWeb, :view
3 |
4 | # If you want to customize a particular status code
5 | # for a certain format, you may uncomment below.
6 | # def render("500.json", _assigns) do
7 | # %{errors: %{detail: "Internal Server Error"}}
8 | # end
9 |
10 | # By default, Phoenix returns the status message from
11 | # the template name. For example, "404.json" becomes
12 | # "Not Found".
13 | def template_not_found(template, _assigns) do
14 | %{
15 | errors: %{
16 | detail: Phoenix.Controller.status_message_from_template(template)
17 | }
18 | }
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/src/test/mock_server/mix.exs:
--------------------------------------------------------------------------------
1 | defmodule MockServer.MixProject do
2 | use Mix.Project
3 |
4 | def project do
5 | [
6 | app: :mock_server,
7 | version: "0.1.9",
8 | elixir: "~> 1.5",
9 | elixirc_paths: elixirc_paths(Mix.env()),
10 | compilers: [:phoenix, :gettext] ++ Mix.compilers(),
11 | start_permanent: Mix.env() == :prod,
12 | deps: deps()
13 | ]
14 | end
15 |
16 | # Configuration for the OTP application.
17 | #
18 | # Type `mix help compile.app` for more information.
19 | def application do
20 | [
21 | mod: {MockServer.Application, []},
22 | extra_applications: [:logger, :runtime_tools]
23 | ]
24 | end
25 |
26 | # Specifies which paths to compile per environment.
27 | defp elixirc_paths(:test), do: ["lib", "test/support"]
28 | defp elixirc_paths(_), do: ["lib"]
29 |
30 | # Specifies your project dependencies.
31 | #
32 | # Type `mix help deps` for examples and options.
33 | defp deps do
34 | [
35 | {:phoenix, "~> 1.6.0"},
36 | {:phoenix_pubsub, "~> 2.0"},
37 | {:gettext, "~> 0.11"},
38 | {:jason, "~> 1.0"},
39 | {:plug_cowboy, "~> 2.0"}
40 | ]
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/src/test/mock_server/mix.lock:
--------------------------------------------------------------------------------
1 | %{
2 | "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
3 | "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
4 | "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
5 | "gettext": {:hex, :gettext, "0.18.2", "7df3ea191bb56c0309c00a783334b288d08a879f53a7014341284635850a6e55", [:mix], [], "hexpm", "f9f537b13d4fdd30f3039d33cb80144c3aa1f8d9698e47d7bcbcc8df93b1f5c5"},
6 | "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
7 | "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"},
8 | "phoenix": {:hex, :phoenix, "1.6.0", "7b85023f7ddef9a5c70909a51cc37c8b868b474d853f90f4280efd26b0e7cce5", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "52ffdd31f2daeb399b2e1eb57d468f99a1ad6eee5d8ea19d2353492f06c9fc96"},
9 | "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
10 | "phoenix_view": {:hex, :phoenix_view, "1.0.0", "fea71ecaaed71178b26dd65c401607de5ec22e2e9ef141389c721b3f3d4d8011", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "82be3e2516f5633220246e2e58181282c71640dab7afc04f70ad94253025db0c"},
11 | "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
12 | "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
13 | "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
14 | "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
15 | "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/mock_server/priv/gettext/en/LC_MESSAGES/errors.po:
--------------------------------------------------------------------------------
1 | ## `msgid`s in this file come from POT (.pot) files.
2 | ##
3 | ## Do not add, change, or remove `msgid`s manually here as
4 | ## they're tied to the ones in the corresponding POT file
5 | ## (with the same domain).
6 | ##
7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge`
8 | ## to merge POT files into PO files.
9 | msgid ""
10 | msgstr ""
11 | "Language: en\n"
12 |
--------------------------------------------------------------------------------
/src/test/mock_server/priv/gettext/errors.pot:
--------------------------------------------------------------------------------
1 | ## This is a PO Template file.
2 | ##
3 | ## `msgid`s here are often extracted from source code.
4 | ## Add new translations manually only if they're dynamic
5 | ## translations that can't be statically extracted.
6 | ##
7 | ## Run `mix gettext.extract` to bring this file up to
8 | ## date. Leave `msgstr`s empty as changing them here has no
9 | ## effect: edit them in PO (`.po`) files instead.
10 |
11 |
--------------------------------------------------------------------------------
/src/test/mock_server/test/mock_server_web/channels/mock_channel_test.exs:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.MockChannelTest do
2 | use MockServerWeb.ChannelCase
3 |
4 | setup do
5 | {:ok, _, socket} =
6 | socket(MockServerWeb.UserSocket, "user_id", %{some: :assign})
7 | |> subscribe_and_join(MockServerWeb.MockChannel, "mock:lobby")
8 |
9 | {:ok, socket: socket}
10 | end
11 |
12 | test "ping replies with status ok", %{socket: socket} do
13 | ref = push(socket, "ping", %{"hello" => "there"})
14 | assert_reply ref, :ok, %{"hello" => "there"}
15 | end
16 |
17 | test "shout broadcasts to mock:lobby", %{socket: socket} do
18 | push(socket, "shout", %{"hello" => "all"})
19 | assert_broadcast "shout", %{"hello" => "all"}
20 | end
21 |
22 | test "broadcasts are pushed to the client", %{socket: socket} do
23 | broadcast_from!(socket, "broadcast", %{"some" => "data"})
24 | assert_push "broadcast", %{"some" => "data"}
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/src/test/mock_server/test/mock_server_web/views/error_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.ErrorViewTest do
2 | use MockServerWeb.ConnCase, async: true
3 |
4 | # Bring render/3 and render_to_string/3 for testing custom views
5 | import Phoenix.View
6 |
7 | test "renders 404.json" do
8 | assert render(MockServerWeb.ErrorView, "404.json", []) == %{
9 | errors: %{detail: "Not Found"}
10 | }
11 | end
12 |
13 | test "renders 500.json" do
14 | assert render(MockServerWeb.ErrorView, "500.json", []) ==
15 | %{errors: %{detail: "Internal Server Error"}}
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/src/test/mock_server/test/support/channel_case.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.ChannelCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | channel tests.
5 |
6 | Such tests rely on `Phoenix.ChannelTest` and also
7 | import other functionality to make it easier
8 | to build common data structures and query the data layer.
9 |
10 | Finally, if the test case interacts with the database,
11 | it cannot be async. For this reason, every test runs
12 | inside a transaction which is reset at the beginning
13 | of the test unless the test case is marked as async.
14 | """
15 |
16 | use ExUnit.CaseTemplate
17 |
18 | using do
19 | quote do
20 | # Import conveniences for testing with channels
21 | use Phoenix.ChannelTest
22 |
23 | # The default endpoint for testing
24 | @endpoint MockServerWeb.Endpoint
25 | end
26 | end
27 |
28 | setup _tags do
29 | :ok
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/src/test/mock_server/test/support/conn_case.ex:
--------------------------------------------------------------------------------
1 | defmodule MockServerWeb.ConnCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | tests that require setting up a connection.
5 |
6 | Such tests rely on `Phoenix.ConnTest` and also
7 | import other functionality to make it easier
8 | to build common data structures and query the data layer.
9 |
10 | Finally, if the test case interacts with the database,
11 | we enable the SQL sandbox, so changes done to the database
12 | are reverted at the end of every test. If you are using
13 | PostgreSQL, you can even run database tests asynchronously
14 | by setting `use MockServerWeb.ConnCase, async: true`, although
15 | this option is not recommendded for other databases.
16 | """
17 |
18 | use ExUnit.CaseTemplate
19 |
20 | using do
21 | quote do
22 | # Import conveniences for testing with connections
23 | use Phoenix.ConnTest
24 | alias MockServerWeb.Router.Helpers, as: Routes
25 |
26 | # The default endpoint for testing
27 | @endpoint MockServerWeb.Endpoint
28 | end
29 | end
30 |
31 | setup _tags do
32 | {:ok, conn: Phoenix.ConnTest.build_conn()}
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/test/mock_server/test/test_helper.exs:
--------------------------------------------------------------------------------
1 | ExUnit.start()
2 |
--------------------------------------------------------------------------------
/src/test/run.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | testdir=$(dirname "$0")
4 |
5 | root=$(pwd)
6 |
7 | cd ${testdir}/mock_server
8 |
9 | mix deps.get || { echo 'Failed to install mix dependencies' ; exit 1; }
10 | mix compile || { echo 'Failed to compile phoenix application' ; exit 1; }
11 |
12 | mix phx.server &
13 | PID=$!
14 |
15 | sleep 2
16 |
17 | ps -p $PID
18 |
19 | if [ $? -ne 0 ]
20 | then
21 | echo $PID
22 | echo "Cannot start mock server"
23 | exit 1
24 | fi
25 |
26 |
27 | cd ${root}
28 |
29 | ./gradlew test
30 | RES=$?
31 |
32 | kill $PID
33 |
34 | exit $RES
35 |
--------------------------------------------------------------------------------