forked from crossbario/autobahn-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the Client class (crossbario#183)
- Loading branch information
Showing
13 changed files
with
161 additions
and
81 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
autobahn/src/main/java/io/crossbar/autobahn/wamp/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.crossbar.autobahn.wamp; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import io.crossbar.autobahn.wamp.interfaces.ITransport; | ||
import io.crossbar.autobahn.wamp.types.ExitInfo; | ||
|
||
public class Client { | ||
private final Session mSession; | ||
private final List<ITransport> mTransports; | ||
private final String mRealm; | ||
private final List<?> mAuthenticators; | ||
|
||
public Client(Session session, List<ITransport> transports, String realm, List<?> authenticators) { | ||
mSession = session; | ||
mTransports = transports; | ||
mRealm = realm; | ||
mAuthenticators = authenticators; | ||
} | ||
|
||
public CompletableFuture<ExitInfo> connect() { | ||
CompletableFuture<ExitInfo> exitFuture = new CompletableFuture<>(); | ||
ExitInfo info = new ExitInfo(); | ||
mSession.addOnConnectListener(() -> mSession.join(mRealm, null)); | ||
mSession.addOnDisconnectListener(() -> exitFuture.complete(info)); | ||
mTransports.get(0).connect(mSession); | ||
return exitFuture; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
autobahn/src/main/java/io/crossbar/autobahn/wamp/interfaces/IAuthenticator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.crossbar.autobahn.wamp.interfaces; | ||
|
||
import io.crossbar.autobahn.wamp.Session; | ||
import io.crossbar.autobahn.wamp.types.Challenge; | ||
|
||
public interface IAuthenticator { | ||
void onChallenge(Session session, Challenge challenge); | ||
} |
4 changes: 1 addition & 3 deletions
4
autobahn/src/main/java/io/crossbar/autobahn/wamp/interfaces/ITransport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
autobahn/src/main/java/io/crossbar/autobahn/wamp/types/Challenge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.crossbar.autobahn.wamp.types; | ||
|
||
import java.util.Map; | ||
|
||
public class Challenge { | ||
public final String method; | ||
public final Map<String, Object> extra; | ||
|
||
public Challenge(String method, Map<String, Object> extra) { | ||
this.method = method; | ||
this.extra = extra; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
autobahn/src/main/java/io/crossbar/autobahn/wamp/types/ExitInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.crossbar.autobahn.wamp.types; | ||
|
||
public class ExitInfo { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.